glsl: Optimize (f2i(trunc x)) into (f2i x).
authorMatt Turner <mattst88@gmail.com>
Fri, 30 Jan 2015 21:42:19 +0000 (13:42 -0800)
committerMatt Turner <mattst88@gmail.com>
Wed, 11 Feb 2015 21:50:19 +0000 (13:50 -0800)
total instructions in shared programs: 5950326 -> 5949286 (-0.02%)
instructions in affected programs:     88264 -> 87224 (-1.18%)
helped:                                692

src/glsl/opt_algebraic.cpp

index 588228c..7bc65da 100644 (file)
@@ -376,6 +376,15 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       }
       break;
 
+   case ir_unop_f2i:
+   case ir_unop_f2u:
+      if (op_expr[0] && op_expr[0]->operation == ir_unop_trunc) {
+         return new(mem_ctx) ir_expression(ir->operation,
+                                           ir->type,
+                                           op_expr[0]->operands[0]);
+      }
+      break;
+
    case ir_unop_logic_not: {
       enum ir_expression_operation new_op = ir_unop_logic_not;