aco/optimizer: use opsel for VOP12C
authorGeorg Lehmann <dadschoorse@gmail.com>
Tue, 21 Mar 2023 12:29:15 +0000 (13:29 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 30 Mar 2023 03:34:34 +0000 (03:34 +0000)
Foz-DB GFX1100:
Totals from 11759 (8.72% of 134864) affected shaders:
VGPRs: 848288 -> 844556 (-0.44%); split: -0.44%, +0.00%
SpillSGPRs: 8527 -> 8543 (+0.19%)
SpillVGPRs: 1411 -> 1423 (+0.85%); split: -0.21%, +1.06%
CodeSize: 114337120 -> 113882472 (-0.40%); split: -0.40%, +0.01%
Scratch: 128768 -> 129024 (+0.20%); split: -0.20%, +0.40%
MaxWaves: 250962 -> 252014 (+0.42%)
Instrs: 22187426 -> 22062378 (-0.56%); split: -0.57%, +0.00%
Latency: 232655375 -> 232376977 (-0.12%); split: -0.20%, +0.08%
InvThroughput: 28292530 -> 28217699 (-0.26%); split: -0.45%, +0.18%
VClause: 352463 -> 352364 (-0.03%); split: -0.12%, +0.10%
SClause: 659282 -> 659354 (+0.01%); split: -0.02%, +0.04%
Copies: 1371369 -> 1342340 (-2.12%); split: -2.30%, +0.19%
Branches: 495903 -> 495941 (+0.01%); split: -0.00%, +0.01%
PreSGPRs: 867295 -> 863664 (-0.42%)
PreVGPRs: 793480 -> 790549 (-0.37%)

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22069>

src/amd/compiler/aco_optimizer.cpp

index 4abf14b..3c84c51 100644 (file)
@@ -1101,9 +1101,8 @@ can_apply_extract(opt_ctx& ctx, aco_ptr<Instruction>& instr, unsigned idx, ssa_i
       if (instr->isSDWA() && instr->sdwa().sel[idx] != SubdwordSel::dword)
          return false;
       return true;
-   } else if (instr->isVOP3() && sel.size() == 2 &&
-              can_use_opsel(ctx.program->gfx_level, instr->opcode, idx) &&
-              !instr->valu().opsel[idx]) {
+   } else if (instr->isVALU() && sel.size() == 2 && !instr->valu().opsel[idx] &&
+              can_use_opsel(ctx.program->gfx_level, instr->opcode, idx)) {
       return true;
    } else if (instr->opcode == aco_opcode::p_extract) {
       SubdwordSel instrSel = parse_extract(instr.get());
@@ -1168,9 +1167,15 @@ apply_extract(opt_ctx& ctx, aco_ptr<Instruction>& instr, unsigned idx, ssa_info&
               (tmp.type() == RegType::vgpr || ctx.program->gfx_level >= GFX9)) {
       to_SDWA(ctx, instr);
       static_cast<SDWA_instruction*>(instr.get())->sel[idx] = sel;
-   } else if (instr->isVOP3()) {
-      if (sel.offset())
+   } else if (instr->isVALU()) {
+      if (sel.offset()) {
          instr->valu().opsel[idx] = true;
+
+         /* VOP12C cannot use opsel with SGPRs. */
+         if (!instr->isVOP3() && !instr->isVINTERP_INREG() &&
+             !info.instr->operands[0].isOfType(RegType::vgpr))
+            instr->format = asVOP3(instr->format);
+      }
    } else if (instr->opcode == aco_opcode::p_extract) {
       SubdwordSel instrSel = parse_extract(instr.get());