diff options
author | Eric Anholt <[email protected]> | 2013-11-07 12:15:13 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-11-15 11:33:07 -0800 |
commit | aa6d7bc6d601c8803b136f427b8d86aa1043450c (patch) | |
tree | 83702cd8c1bcf5bf3c31f94c0cb7ae3680eba2ee /src/glsl/opt_algebraic.cpp | |
parent | 477f8cd08bb8467d28fdfd6c25fe358957e3da58 (diff) |
glsl: Apply the transformation "1/rsq(x) == sqrt(x)" in opt_algebraic.
The comment was stale, because the lowering in question wasn't happening
in lower_instructions.cpp. Presumably if the lowering ever moves there,
we can plumb the lowering mask through to opt_algebraic.
total instructions in shared programs: 1618696 -> 1616810 (-0.12%)
instructions in affected programs: 243018 -> 241132 (-0.78%)
GAINED: 0
LOST: 0
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/glsl/opt_algebraic.cpp')
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 448f27ed954..05a58998985 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -420,10 +420,11 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp) return op_expr[0]->operands[0]; - /* FINISHME: We should do rcp(rsq(x)) -> sqrt(x) for some - * backends, except that some backends will have done sqrt -> - * rcp(rsq(x)) and we don't want to undo it for them. + /* While ir_to_mesa.cpp will lower sqrt(x) to rcp(rsq(x)), it does so at + * its IR level, so we can always apply this transformation. */ + if (op_expr[0] && op_expr[0]->operation == ir_unop_rsq) + return sqrt(op_expr[0]->operands[0]); /* As far as we know, all backends are OK with rsq. */ if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) { |