Module: Mesa
Branch: main
Commit: 55f692c451871b90ca6ced032076023a2c69df23
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=55f692c451871b90ca6ced032076023a2c69df23

Author: Gert Wollny <[email protected]>
Date:   Sat Jul 22 18:22:07 2023 +0200

r600/sfn: Always check arrays writes before allowing copy propagation

Also propaate extra dependencies when an indirect load is propagated

Signed-off-by: Gert Wollny <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24297>

---

 src/gallium/drivers/r600/sfn/sfn_optimizer.cpp | 38 +++++++++++++++++---------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp 
b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp
index 986019a158d..c2f6183ccfb 100644
--- a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp
@@ -407,25 +407,29 @@ CopyPropFwdVisitor::visit(AluInstr *instr)
             }
          }
       }
-
+      bool move_addr_use = false;
       bool src_can_propagate = false;
       if (auto rsrc = src->as_register()) {
          if (rsrc->has_flag(Register::ssa)) {
             src_can_propagate = true;
          } else if (mov_block_id == target_block_id) {
-            if (rsrc->addr()) {
-               if (i->block_id() == mov_block_id &&
-                   i->index() == instr->index() + 1)
+            if (auto a = rsrc->addr()) {
+               if (a->as_register() &&
+                   !a->as_register()->has_flag(Register::addr_or_idx) &&
+                   i->block_id() == mov_block_id &&
+                   i->index() == instr->index() + 1) {
                   src_can_propagate = true;
+                  move_addr_use = true;
+               }
             } else {
                src_can_propagate = true;
-               for (auto p : rsrc->parents()) {
-                  if (p->block_id() == mov_block_id &&
-                      p->index() > instr->index() &&
-                      p->index() < i->index()) {
-                     src_can_propagate = false;
-                     break;
-                  }
+            }
+            for (auto p : rsrc->parents()) {
+               if (p->block_id() == mov_block_id &&
+                   p->index() > instr->index() &&
+                   p->index() < i->index()) {
+                  src_can_propagate = false;
+                  break;
                }
             }
          }
@@ -439,8 +443,16 @@ CopyPropFwdVisitor::visit(AluInstr *instr)
 
          if (i->as_alu() && i->as_alu()->parent_group()) {
             progress |= i->as_alu()->parent_group()->replace_source(dest, src);
-         } else
-            progress |= i->replace_source(dest, src);
+         } else {
+            bool success = i->replace_source(dest, src);
+            if (success && move_addr_use) {
+               for (auto r : instr->required_instr()){
+                  std::cerr << "add " << *r << " to " << *i << "\n";
+                  i->add_required_instr(r);
+               }
+            }
+            progress |= success;
+         }
       }
    }
    if (instr->dest()) {

Reply via email to