summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-04-02 20:17:17 -0700
committerEric Anholt <[email protected]>2011-04-13 10:51:03 -0700
commit487debfda56ad3855db655688186401b0dd75233 (patch)
treeaf08c9930876428de0c105220e9fc9408d630cfe
parentb9c8b2a1f1b2fe2e02b314790ebdc465f0ffec6e (diff)
glsl/opt_cpe: Kill when the assignment isn't something we recognize.
A few GLES2 tests tripped over this when using array dereferences to hit channels on the LHS (see piglit test glsl-copy-propagation-vector-indexing). We wouldn't find the ir_dereference_variable, and assume that that meant that it wasn't an assignment to a scalar/vector, and thus not notice that the variable had been changed.
-rw-r--r--src/glsl/opt_copy_propagation_elements.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp
index 8541d9a8ee1..1ffbd4da144 100644
--- a/src/glsl/opt_copy_propagation_elements.cpp
+++ b/src/glsl/opt_copy_propagation_elements.cpp
@@ -161,9 +161,16 @@ ir_visitor_status
ir_copy_propagation_elements_visitor::visit_leave(ir_assignment *ir)
{
ir_dereference_variable *lhs = ir->lhs->as_dereference_variable();
+ ir_variable *var = ir->lhs->variable_referenced();
+
+ if (var->type->is_scalar() || var->type->is_vector()) {
+ kill_entry *k;
+
+ if (lhs)
+ k = new(mem_ctx) kill_entry(var, ir->write_mask);
+ else
+ k = new(mem_ctx) kill_entry(var, ~0);
- if (lhs && (lhs->type->is_scalar() || lhs->type->is_vector())) {
- kill_entry *k = new(mem_ctx) kill_entry(lhs->var, ir->write_mask);
kill(k);
}