glsl: Optimize pow(1.0, X) --> 1.0.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 6 Jan 2014 06:19:42 +0000 (22:19 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 7 Jan 2014 20:54:57 +0000 (12:54 -0800)
Surprisingly, this helps one vertex shader in 3DMMES.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/opt_algebraic.cpp

index 05a5899898555b89d86de1497e079b0b1e4c4a3a..5e885f786483a28191a33f2700d9fd1ae6389a6b 100644 (file)
@@ -416,6 +416,12 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       }
       break;
 
+   case ir_binop_pow:
+      /* 1^x == 1 */
+      if (is_vec_one(op_const[0]))
+         return op_const[0];
+      break;
+
    case ir_unop_rcp:
       if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp)
         return op_expr[0]->operands[0];