glsl/opt_algebraic: Don't handle invariant or precise trees
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 17 Mar 2016 21:41:14 +0000 (14:41 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 23 Mar 2016 23:28:07 +0000 (16:28 -0700)
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/compiler/glsl/opt_algebraic.cpp

index 1e58062cb0d804fb65b5e036be4896f6a6155649..f5858c838654c508ec3335b24ecf0636d0ac5f9a 100644 (file)
@@ -58,6 +58,8 @@ public:
    {
    }
 
+   virtual ir_visitor_status visit_enter(ir_assignment *ir);
+
    ir_rvalue *handle_expression(ir_expression *ir);
    void handle_rvalue(ir_rvalue **rvalue);
    bool reassociate_constant(ir_expression *ir1,
@@ -80,6 +82,23 @@ public:
 
 } /* unnamed namespace */
 
+ir_visitor_status
+ir_algebraic_visitor::visit_enter(ir_assignment *ir)
+{
+   ir_variable *var = ir->lhs->variable_referenced();
+   if (var->data.invariant || var->data.precise) {
+      /* If we're assigning to an invariant or precise variable, just bail.
+       * Most of the algebraic optimizations aren't precision-safe.
+       *
+       * FINISHME: Find out which optimizations are precision-safe and enable
+       * then only for invariant or precise trees.
+       */
+      return visit_continue_with_parent;
+   } else {
+      return visit_continue;
+   }
+}
+
 static inline bool
 is_vec_zero(ir_constant *ir)
 {