[Mesa-dev] [PATCH 2/2] glsl: Make copy propagation loop through copy-chains

Thomas Helland thomashelland90 at gmail.com
Thu Jan 5 17:44:38 UTC 2017


This should allow us to resolve copy propagation faster,
as we don't need multiple runs of the pass when we have situations like:

foo = bar;
baz = foo;
---
 src/compiler/glsl/opt_copy_propagation.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/opt_copy_propagation.cpp b/src/compiler/glsl/opt_copy_propagation.cpp
index b164a9dcc8..b7c7d02d2f 100644
--- a/src/compiler/glsl/opt_copy_propagation.cpp
+++ b/src/compiler/glsl/opt_copy_propagation.cpp
@@ -189,8 +189,10 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir)
    struct hash_entry *entry = _mesa_hash_table_search(acp, ir->var);
    if (entry) {
       acp_entry *this_acp_entry = (acp_entry *) entry->data;
-      if (this_acp_entry->replacement && !this_acp_entry->replacement->dead) {
-         ir->var = (ir_variable *) this_acp_entry->replacement->var;
+      while (this_acp_entry->replacement && !this_acp_entry->replacement->dead) {
+         entry = _mesa_hash_table_search(acp, this_acp_entry->replacement->var);
+         this_acp_entry = (acp_entry *) entry->data;
+         ir->var = this_acp_entry->var;
          progress = true;
       }
    }
-- 
2.11.0



More information about the mesa-dev mailing list