glsl/rebalance_tree: Don't handle invariant or precise trees
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 17 Mar 2016 21:44:57 +0000 (14:44 -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_rebalance_tree.cpp

index 095f2d7d2f079b7e7a57212de23f3b70388d5eca..8045d51033db21a6e036126adf9d3591795301f4 100644 (file)
@@ -131,6 +131,8 @@ public:
       progress = false;
    }
 
+   virtual ir_visitor_status visit_enter(ir_assignment *ir);
+
    void handle_rvalue(ir_rvalue **rvalue);
 
    bool progress;
@@ -146,6 +148,20 @@ struct is_reduction_data {
 
 } /* anonymous namespace */
 
+ir_visitor_status
+ir_rebalance_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 variable, just bail.  Tree
+       * rebalancing (reassociation) isn't precision-safe.
+       */
+      return visit_continue_with_parent;
+   } else {
+      return visit_continue;
+   }
+}
+
 static bool
 is_reduction_operation(ir_expression_operation operation)
 {