[PATCH] D98631: AMDGPU: Don't require registers for s_setpc_b64 operand

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 15 06:00:54 PDT 2021


arsenm created this revision.
arsenm added reviewers: rampitec, dp.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

The pseudo was using SSrc_b64, so it allowed folding immediates into
the destination operand for a tail call to null. This would be printed
as an invalid immediate operand. I don't see any restriction noted
that this must be a register, so just allow any SSrc_b64 like normal.

      

Avoids a regression when tail calls are enabled in GlobalISel (somehow
tail calls to null get deleted in the DAG).


https://reviews.llvm.org/D98631

Files:
  llvm/lib/Target/AMDGPU/SOPInstructions.td
  llvm/test/MC/AMDGPU/sop1.s


Index: llvm/test/MC/AMDGPU/sop1.s
===================================================================
--- llvm/test/MC/AMDGPU/sop1.s
+++ llvm/test/MC/AMDGPU/sop1.s
@@ -218,6 +218,11 @@
 // GFX89: s_setpc_b64 s[4:5] ; encoding: [0x04,0x1d,0x80,0xbe]
 // GFX10: s_setpc_b64 s[4:5] ; encoding: [0x04,0x20,0x80,0xbe]
 
+s_setpc_b64 0
+// SICI: s_setpc_b64 0 ; encoding: [0x80,0x20,0x80,0xbe]
+// GFX89: s_setpc_b64 0 ; encoding: [0x80,0x1d,0x80,0xbe]
+// GFX10: s_setpc_b64 0 ; encoding: [0x80,0x20,0x80,0xbe]
+
 s_swappc_b64 s[2:3], s[4:5]
 // SICI: s_swappc_b64 s[2:3], s[4:5] ; encoding: [0x04,0x21,0x82,0xbe]
 // GFX89: s_swappc_b64 s[2:3], s[4:5] ; encoding: [0x04,0x1e,0x82,0xbe]
Index: llvm/lib/Target/AMDGPU/SOPInstructions.td
===================================================================
--- llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -147,7 +147,7 @@
 }
 
 // 64-bit input, no output
-class SOP1_1 <string opName, RegisterClass rc = SReg_64, list<dag> pattern=[]> : SOP1_Pseudo <
+class SOP1_1 <string opName, RegisterOperand rc = SSrc_b64, list<dag> pattern=[]> : SOP1_Pseudo <
   opName, (outs), (ins rc:$src0), "$src0", pattern> {
   let has_sdst = 0;
 }
@@ -254,7 +254,8 @@
 
 let isReturn = 1 in {
 // Define variant marked as return rather than branch.
-def S_SETPC_B64_return : SOP1_1<"", CCR_SGPR_64, [(AMDGPUret_flag i64:$src0)]>;
+def S_SETPC_B64_return : SOP1_1<"", RegisterOperand<CCR_SGPR_64>,
+  [(AMDGPUret_flag i64:$src0)]>;
 }
 } // End isTerminator = 1, isBarrier = 1
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98631.330628.patch
Type: text/x-patch
Size: 1548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210315/4e459b8a/attachment.bin>


More information about the llvm-commits mailing list