[llvm] [AMDGPU] Waterfall loop codegen improvement in SIInstrInfo (PR #192415)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 05:27:06 PDT 2026


================
@@ -7175,25 +7206,36 @@ static void emitLoadScalarOpsFromVGPRLoop(
             .addReg(CurRegHi)
             .addImm(AMDGPU::sub1);
 
-        Register NewCondReg = MRI.createVirtualRegister(BoolXExecRC);
-        auto Cmp = BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_CMP_EQ_U64_e64),
-                           NewCondReg)
-                       .addReg(CurReg);
-        if (NumSubRegs <= 2)
-          Cmp.addReg(VScalarOp);
-        else
-          Cmp.addReg(VScalarOp, VScalarOpUndef,
-                     TRI->getSubRegFromChannel(Idx, 2));
-
-        // Combine the comparison results with AND.
-        if (!CondReg) // First.
-          CondReg = NewCondReg;
-        else { // If not the first, we create an AND.
-          Register AndReg = MRI.createVirtualRegister(BoolXExecRC);
-          BuildMI(LoopBB, I, DL, TII.get(LMC.AndOpc), AndReg)
-              .addReg(CondReg)
-              .addReg(NewCondReg);
-          CondReg = AndReg;
+        if (UseNewExecInstructions) {
+          auto CmpX =
+              BuildMI(LoopBB, I, DL, TII.get(LMC.CmpXEqU64Opc)).addReg(CurReg);
+
+          if (NumSubRegs <= 2)
+            CmpX.addReg(VScalarOp);
----------------
arsenm wrote:

I don't understand why this case drops the VScalarOpUndef flags. This could be one addReg call that conditional sets the subreg 

https://github.com/llvm/llvm-project/pull/192415


More information about the llvm-commits mailing list