Module: Mesa
Branch: master
Commit: d000d76f13e24aae701de0d4ab43bc06c3c9b361
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d000d76f13e24aae701de0d4ab43bc06c3c9b361

Author: Daniel Schürmann <[email protected]>
Date:   Wed Apr 15 11:24:39 2020 +0100

aco: use upper part of gap in register file if it is beneficial for striding

Totals from affected shaders:
SGPRS: 1717288 -> 1716984 (-0.02 %)
VGPRS: 1305924 -> 1304904 (-0.08 %)
Code Size: 138508892 -> 138420144 (-0.06 %) bytes
Max Waves: 115726 -> 115735 (0.01 %)

Reviewed-by: Rhys Perry <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4573>

---

 src/amd/compiler/aco_register_allocation.cpp | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/amd/compiler/aco_register_allocation.cpp 
b/src/amd/compiler/aco_register_allocation.cpp
index eae3822e61c..30be43a7f87 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -440,14 +440,25 @@ std::pair<PhysReg, bool> get_reg_simple(ra_ctx& ctx,
       }
 
       /* final check */
-      if (last_pos + size <= ub && ub - last_pos < gap_size)
+      if (last_pos + size <= ub && ub - last_pos < gap_size) {
          best_pos = last_pos;
+         gap_size = ub - last_pos;
+      }
+
+      if (best_pos == 0xFFFF)
+         return {{}, false};
 
-      if (best_pos != 0xFFFF) {
-         adjust_max_used_regs(ctx, rc, best_pos);
-         return {PhysReg{best_pos}, true};
+      /* find best position within gap by leaving a good stride for other 
variables*/
+      unsigned buffer = gap_size - size;
+      if (buffer > 1) {
+         if (((best_pos + size) % 8 != 0 && (best_pos + buffer) % 8 == 0) ||
+             ((best_pos + size) % 4 != 0 && (best_pos + buffer) % 4 == 0) ||
+             ((best_pos + size) % 2 != 0 && (best_pos + buffer) % 2 == 0))
+            best_pos = best_pos + buffer;
       }
-      return {{}, false};
+
+      adjust_max_used_regs(ctx, rc, best_pos);
+      return {PhysReg{best_pos}, true};
    }
 
    bool found = false;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to