summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-07-02 11:27:06 -0700
committerEric Anholt <eric@anholt.net>2010-07-02 11:27:06 -0700
commit9a0e421983edc31371440c08687fa2bb2207924d (patch)
tree95b2cab4e5f98cb61c5e4a8075186289f8526f08 /src/mesa
parent667f4e1940c4c4660e35dc9906672a476369660f (diff)
glsl2: Add a pass to break ir_binop_div to _mul and _rcp.
This results in constant folding of a constant divisor.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/ir_to_mesa.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 7c7e368d0d..d5664e7b91 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -691,9 +691,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
}
break;
case ir_binop_div:
- ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[1]);
- ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], result_src);
- break;
+ assert(!"not reached: should be handled by ir_div_to_mul_rcp");
case ir_binop_mod:
assert(!"ir_binop_mod should have been converted to b * fract(a/b)");
break;
@@ -1729,6 +1727,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
/* Lowering */
do_mod_to_fract(shader->ir);
+ do_div_to_mul_rcp(shader->ir);
/* Optimization passes */
if (!state->error && !shader->ir->is_empty()) {