summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_copy_propagation.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-08-27 16:22:36 -0700
committerIan Romanick <[email protected]>2010-09-03 11:55:22 -0700
commit4e5b41c2f6b6423d0df260a9dea7938546134ec6 (patch)
tree0da43f750a31ab45cd57960ca507ac95323eab6b /src/glsl/ir_copy_propagation.cpp
parentde7c3fe31a7b88a5392dceee3b13b45ed78cdeae (diff)
glsl2: Allow copy / constant propagation into array indices
Diffstat (limited to 'src/glsl/ir_copy_propagation.cpp')
-rw-r--r--src/glsl/ir_copy_propagation.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp
index 6c211f0e70a..0fe8fa6c419 100644
--- a/src/glsl/ir_copy_propagation.cpp
+++ b/src/glsl/ir_copy_propagation.cpp
@@ -84,7 +84,7 @@ public:
virtual ir_visitor_status visit_enter(class ir_loop *);
virtual ir_visitor_status visit_enter(class ir_function_signature *);
virtual ir_visitor_status visit_enter(class ir_function *);
- virtual ir_visitor_status visit_enter(class ir_assignment *);
+ virtual ir_visitor_status visit_leave(class ir_assignment *);
virtual ir_visitor_status visit_enter(class ir_call *);
virtual ir_visitor_status visit_enter(class ir_if *);
@@ -132,30 +132,13 @@ ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir)
}
ir_visitor_status
-ir_copy_propagation_visitor::visit_enter(ir_assignment *ir)
+ir_copy_propagation_visitor::visit_leave(ir_assignment *ir)
{
- ir_visitor_status s;
-
- /* ir_assignment::accept(ir_hv *v), skipping the LHS so that we can
- * avoid copy propagating into the LHS.
- *
- * Note that this means we won't copy propagate into the derefs of
- * an array index. Oh well.
- */
-
- s = ir->rhs->accept(this);
- assert(s == visit_continue);
-
- if (ir->condition) {
- s = ir->condition->accept(this);
- assert(s == visit_continue);
- }
-
kill(ir->lhs->variable_referenced());
add_copy(ir);
- return visit_continue_with_parent;
+ return visit_continue;
}
ir_visitor_status
@@ -175,6 +158,9 @@ ir_copy_propagation_visitor::visit_enter(ir_function *ir)
ir_visitor_status
ir_copy_propagation_visitor::visit(ir_dereference_variable *ir)
{
+ if (this->in_assignee)
+ return visit_continue;
+
ir_variable *var = ir->var;
foreach_iter(exec_list_iterator, iter, *this->acp) {