[PATCH] D125976: [AMDGPU] Allow multiple uses of the same literal in SOP2/SOPC
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 07:23:37 PDT 2022
foad created this revision.
foad added reviewers: dstuttard, arsenm, rampitec, piotr.
Herald added subscribers: kosarev, jsilvanus, hsmhsm, kerbowa, hiraditya, t-tye, tpr, yaxunl, nhaehnle, jvesely, kzhuravl.
Herald added a project: All.
foad requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125976
Files:
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/test/CodeGen/AMDGPU/verify-duplicate-literal.mir
Index: llvm/test/CodeGen/AMDGPU/verify-duplicate-literal.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/verify-duplicate-literal.mir
+++ llvm/test/CodeGen/AMDGPU/verify-duplicate-literal.mir
@@ -26,3 +26,19 @@
; CHECK: $vgpr0 = V_FMA_F32_e64 0, $vgpr0, 0, 1077936128, 0, 1077936128, 0, 0, implicit $mode, implicit $exec
$vgpr0 = V_FMA_F32_e64 0, $vgpr0, 0, 1077936128, 0, 1077936128, 0, 0, implicit $mode, implicit $exec
...
+
+---
+name: use_duplicate_literal_sop2
+tracksRegLiveness: true
+body: |
+ bb.0:
+ $sgpr0 = S_ADD_U32 12345, 12345, implicit-def $scc
+...
+
+---
+name: use_duplicate_literal_sopc
+tracksRegLiveness: true
+body: |
+ bb.0:
+ S_CMP_LG_U32 305419896, 305419896, implicit-def $scc
+...
Index: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -4366,16 +4366,11 @@
if (isSOP2(MI) || isSOPC(MI)) {
const MachineOperand &Src0 = MI.getOperand(Src0Idx);
const MachineOperand &Src1 = MI.getOperand(Src1Idx);
- unsigned Immediates = 0;
- if (!Src0.isReg() &&
- !isInlineConstant(Src0, Desc.OpInfo[Src0Idx].OperandType))
- Immediates++;
- if (!Src1.isReg() &&
- !isInlineConstant(Src1, Desc.OpInfo[Src1Idx].OperandType))
- Immediates++;
-
- if (Immediates > 1) {
+ if (!Src0.isReg() && !Src1.isReg() &&
+ !isInlineConstant(Src0, Desc.OpInfo[Src0Idx].OperandType) &&
+ !isInlineConstant(Src1, Desc.OpInfo[Src1Idx].OperandType) &&
+ !Src0.isIdenticalTo(Src1)) {
ErrInfo = "SOP2/SOPC instruction requires too many immediate constants";
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125976.430670.patch
Type: text/x-patch
Size: 1777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220519/63fcf3ab/attachment.bin>
More information about the llvm-commits
mailing list