glsl: Make opt_copy_propagation_elements actually propagate into loops.

We've had a FINISHME here since Eric originally wrote the code in 2011.
This patch implements his suggested approach, which makes us actually
able to copy propagate into the loops, at the unfortunate cost of making
this pass even more expensive.

The shader-db statistics are basically a wash:

   No change in instruction counts.

   total cycles in shared programs: 78685980 -> 78680730 (-0.01%)
   cycles in affected programs: 2102646 -> 2097396 (-0.25%)
   helped: 48
   HURT: 83

I figured if we're going to do this for one copy propagation pass,
we may as well do it in both.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Kenneth Graunke
2016-04-29 22:06:37 -07:00
parent 0756e3a25c
commit 13b859de04

View File

@@ -106,6 +106,7 @@ public:
ralloc_free(mem_ctx);
}
void handle_loop(ir_loop *, bool keep_acp);
virtual ir_visitor_status visit_enter(class ir_loop *);
virtual ir_visitor_status visit_enter(class ir_function_signature *);
virtual ir_visitor_status visit_leave(class ir_assignment *);
@@ -374,8 +375,8 @@ ir_copy_propagation_elements_visitor::visit_enter(ir_if *ir)
return visit_continue_with_parent;
}
ir_visitor_status
ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir)
void
ir_copy_propagation_elements_visitor::handle_loop(ir_loop *ir, bool keep_acp)
{
exec_list *orig_acp = this->acp;
exec_list *orig_kills = this->kills;
@@ -389,6 +390,13 @@ ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir)
this->kills = new(mem_ctx) exec_list;
this->killed_all = false;
if (keep_acp) {
/* Populate the initial acp with a copy of the original */
foreach_in_list(acp_entry, a, orig_acp) {
this->acp->push_tail(new(this->acp) acp_entry(a));
}
}
visit_list_elements(this, &ir->body_instructions);
if (this->killed_all) {
@@ -406,6 +414,13 @@ ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir)
}
ralloc_free(new_kills);
}
ir_visitor_status
ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir)
{
handle_loop(ir, false);
handle_loop(ir, true);
/* already descended into the children. */
return visit_continue_with_parent;