aco: Remove MTBUF zero operand.
authorTimur Kristóf <timur.kristof@gmail.com>
Thu, 2 Feb 2023 23:32:06 +0000 (00:32 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 16 Feb 2023 17:16:34 +0000 (17:16 +0000)
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/21363>

src/amd/compiler/aco_optimizer.cpp

index 3e29556..a75ca2a 100644 (file)
@@ -1512,6 +1512,22 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
          }
       }
 
+      else if (instr->isMTBUF()) {
+         MTBUF_instruction& mtbuf = instr->mtbuf();
+         while (info.is_temp())
+            info = ctx.info[info.temp.id()];
+
+         if (mtbuf.offen && mtbuf.idxen && i == 1 && info.is_vec() &&
+             info.instr->operands.size() == 2 && info.instr->operands[0].isTemp() &&
+             info.instr->operands[0].regClass() == v1 && info.instr->operands[1].isConstant() &&
+             mtbuf.offset + info.instr->operands[1].constantValue() < 4096) {
+            instr->operands[1] = info.instr->operands[0];
+            mtbuf.offset += info.instr->operands[1].constantValue();
+            mtbuf.offen = false;
+            continue;
+         }
+      }
+
       /* SCRATCH: propagate constants and combine additions */
       else if (instr->isScratch()) {
          FLAT_instruction& scratch = instr->scratch();