From 9a0e421983edc31371440c08687fa2bb2207924d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Jul 2010 11:27:06 -0700 Subject: glsl2: Add a pass to break ir_binop_div to _mul and _rcp. This results in constant folding of a constant divisor. --- src/mesa/shader/ir_to_mesa.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 7c7e368d0d5..d5664e7b91e 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()) { -- cgit v1.2.3