[llvm] [AMDGPU] Allocate i1 argument to SGPRs (PR #72461)

Jun Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 15:23:44 PST 2023


================
@@ -715,6 +715,14 @@ bool SILowerI1Copies::lowerCopiesToI1() {
       assert(!MI.getOperand(1).getSubReg());
 
       if (!SrcReg.isVirtual() || (!isLaneMaskReg(SrcReg) && !isVreg1(SrcReg))) {
+        if (!SrcReg.isVirtual() &&
+            TII->getRegisterInfo().getRegSizeInBits(SrcReg, *MRI) == 64) {
+          // When calling convention allocates SGPR for i1, for GPUs with
+          // wavefront size 64, i1 return value is put in 64b SGPR.
+          assert(ST->isWave64());
+          continue;
+        }
+
----------------
jwanggit86 wrote:

Immediate after these new lines is an assert():
`assert(TII->getRegisterInfo().getRegSizeInBits(SrcReg, *MRI) == 32);`
which makes sure SrcReg is 32b before lowering the copy to `V_CMP_NE_U32_e64`.

Because, with the callingconv change, the i1 return value is in an SGPR_64 (for wave64 GPUs), these lines were inserted to avoid triggering the assert.

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


More information about the llvm-commits mailing list