aco: Support s_cselect_b64 in SCC no-compare optimization.
authorTimur Kristóf <timur.kristof@gmail.com>
Wed, 23 Mar 2022 17:45:36 +0000 (18:45 +0100)
committerMarge Bot <emma+marge@anholt.net>
Sat, 20 Aug 2022 15:27:40 +0000 (15:27 +0000)
This was simply left out by accident when I wrote this.

Fossil DB stats on Navi 21:

Totals from 70165 (52.01% of 134906) affected shaders:
CodeSize: 246375656 -> 245814396 (-0.23%)
Instrs: 46519773 -> 46379458 (-0.30%)
Latency: 385159303 -> 385089261 (-0.02%); split: -0.02%, +0.00%
InvThroughput: 66490172 -> 66487867 (-0.00%); split: -0.00%, +0.00%

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16266>

src/amd/compiler/aco_optimizer_postRA.cpp

index 276e619..a59ee83 100644 (file)
@@ -327,11 +327,13 @@ try_optimize_scc_nocompare(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
             : aco_opcode::s_cmp_lg_u32;
    } else if ((instr->format == Format::PSEUDO_BRANCH && instr->operands.size() == 1 &&
                instr->operands[0].physReg() == scc) ||
-              instr->opcode == aco_opcode::s_cselect_b32) {
+              instr->opcode == aco_opcode::s_cselect_b32 ||
+              instr->opcode == aco_opcode::s_cselect_b64) {
 
       /* For cselect, operand 2 is the SCC condition */
       unsigned scc_op_idx = 0;
-      if (instr->opcode == aco_opcode::s_cselect_b32) {
+      if (instr->opcode == aco_opcode::s_cselect_b32 ||
+          instr->opcode == aco_opcode::s_cselect_b64) {
          scc_op_idx = 2;
       }
 
@@ -359,7 +361,8 @@ try_optimize_scc_nocompare(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
          if (instr->format == Format::PSEUDO_BRANCH)
             instr->opcode = instr->opcode == aco_opcode::p_cbranch_z ? aco_opcode::p_cbranch_nz
                                                                      : aco_opcode::p_cbranch_z;
-         else if (instr->opcode == aco_opcode::s_cselect_b32)
+         else if (instr->opcode == aco_opcode::s_cselect_b32 ||
+                  instr->opcode == aco_opcode::s_cselect_b64)
             std::swap(instr->operands[0], instr->operands[1]);
          else
             unreachable(