copy_propagation: do propagation into non-out call params
authorAras Pranckevicius <aras@unity3d.com>
Fri, 6 Aug 2010 14:09:02 +0000 (16:09 +0200)
committerEric Anholt <eric@anholt.net>
Fri, 6 Aug 2010 21:13:15 +0000 (14:13 -0700)
src/glsl/ir_copy_propagation.cpp

index 1d28392d7c38e2e9cb532c15909878fcb6325f51..90a49d5a82ac1f52abf8abed8d298f3fc7c1b303 100644 (file)
@@ -164,11 +164,17 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir)
 ir_visitor_status
 ir_copy_propagation_visitor::visit_enter(ir_call *ir)
 {
-   (void)ir;
-
-   /* Note, if we were to do copy propagation to parameters of calls, we'd
-    * have to be careful about out params.
-    */
+   /* Do copy propagation on call parameters, but skip any out params */
+   exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator();
+   foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
+      ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
+      ir_instruction *ir = (ir_instruction *)iter.get();
+      if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout &&
+         sig_param->mode != ir_var_uniform) {
+         ir->accept(this);
+      }
+      sig_param_iter.next();
+   }
    return visit_continue_with_parent;
 }