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

Author: Timur Kristóf <[email protected]>
Date:   Fri May  7 15:03:36 2021 +0200

aco: Don't use s_and_saveexec with branches when exec is constant.

When exec is constant, we can remember the constant as the old exec,
and just copy the condition and use it as the new exec. There is no
need to save the constant.

Due to using p_parallelcopy which is lowered to s_mov_b64 (or 32),
many exec restores now become copies, hence the increase in the copy
stats.

Fossil DB changes on Sienna Cichlid:

Totals from 73969 (49.37% of 149839) affected shaders:
SpillSGPRs: 1768 -> 1610 (-8.94%)
CodeSize: 99053892 -> 99047884 (-0.01%); split: -0.02%, +0.01%
Instrs: 19372852 -> 19370398 (-0.01%); split: -0.02%, +0.01%
VClause: 515154 -> 515142 (-0.00%); split: -0.00%, +0.00%
SClause: 719236 -> 718395 (-0.12%); split: -0.14%, +0.02%
Copies: 1109770 -> 1254634 (+13.05%); split: -0.07%, +13.12%
Branches: 374338 -> 374348 (+0.00%); split: -0.00%, +0.00%
PreSGPRs: 1776481 -> 1653761 (-6.91%)

Signed-off-by: Timur Kristóf <[email protected]>
Reviewed-by: Tony Wasserka <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10691>

---

 src/amd/compiler/aco_insert_exec_mask.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/amd/compiler/aco_insert_exec_mask.cpp 
b/src/amd/compiler/aco_insert_exec_mask.cpp
index e39b5a40153..11bec77e6cf 100644
--- a/src/amd/compiler/aco_insert_exec_mask.cpp
+++ b/src/amd/compiler/aco_insert_exec_mask.cpp
@@ -966,11 +966,14 @@ void add_branch_code(exec_ctx& ctx, Block* block)
          transition_to_Exact(ctx, bld, idx);
 
       uint8_t mask_type = ctx.info[idx].exec.back().second & (mask_type_wqm | 
mask_type_exact);
+      if (ctx.info[idx].exec.back().first.constantEquals(-1u)) {
+         bld.pseudo(aco_opcode::p_parallelcopy, Definition(exec, bld.lm), 
cond);
+      } else {
+         Temp old_exec = bld.sop1(Builder::s_and_saveexec, bld.def(bld.lm), 
bld.def(s1, scc),
+                                 Definition(exec, bld.lm), cond, Operand(exec, 
bld.lm));
 
-      Temp old_exec = bld.sop1(Builder::s_and_saveexec, bld.def(bld.lm), 
bld.def(s1, scc),
-                               Definition(exec, bld.lm), cond, Operand(exec, 
bld.lm));
-
-      ctx.info[idx].exec.back().first = Operand(old_exec);
+         ctx.info[idx].exec.back().first = Operand(old_exec);
+      }
 
       /* add next current exec to the stack */
       ctx.info[idx].exec.emplace_back(Operand(bld.lm), mask_type);

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

Reply via email to