[llvm] [AMDGPU] ISel for @llvm.amdgcn.cs.chain intrinsic (PR #68186)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 08:11:38 PDT 2023


================
@@ -1283,6 +1293,23 @@ bool AMDGPUCallLowering::lowerTailCall(
     MIRBuilder.buildInstr(AMDGPU::ADJCALLSTACKDOWN).addImm(NumBytes).addImm(0);
   }
 
+  // If this is a chain call, we need to set EXEC right before the call.
+  if (AMDGPU::isChainCC(Info.CallConv)) {
+    ArgInfo ExecArg = Info.OrigArgs[1];
+    assert(ExecArg.Regs.size() == 1 && "Too many regs for EXEC");
+
+    if (!ExecArg.Ty->isIntegerTy(ST.getWavefrontSize()))
+      return false;
+
+    unsigned MovOpc = ST.isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
+    MCRegister Exec = TRI->getExec();
+    auto SetExec =
+        MIRBuilder.buildInstr(MovOpc).addDef(Exec).addReg(ExecArg.Regs[0]);
----------------
ruiling wrote:

I have some concerns about the exec setup here:
1. Have you checked that a vgpr used in WWM calculation will be restored before the exec setup? Maybe adding a test for this?
2. I feel it would be better we add kind of implicit dependency on `EXEC` to the real call instruction after the exec-setup to explicitly say the call afterward depends on this EXEC setup. This might be helpful to avoid stupid things happening.

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


More information about the llvm-commits mailing list