[PATCH] D148716: [AMDGPU] NFC. Refactor GISel for cmp intrinsics
Joe Nash via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 08:20:35 PDT 2023
Joe_Nash created this revision.
Joe_Nash added reviewers: kosarev, foad.
Herald added subscribers: StephenFan, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
Joe_Nash requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Combine the logic for fcmp and icmp intrinsics and use operand presence
instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148716
Files:
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -1291,27 +1291,26 @@
if (Opcode == -1)
return false;
- MachineInstr *SelectedMI;
- if (CmpInst::isFPPredicate(Pred)) {
- MachineOperand &LHS = I.getOperand(2);
- MachineOperand &RHS = I.getOperand(3);
- auto [Src0, Src0Mods] = selectVOP3ModsImpl(LHS);
- auto [Src1, Src1Mods] = selectVOP3ModsImpl(RHS);
- Register Src0Reg =
- copyToVGPRIfSrcFolded(Src0, Src0Mods, LHS, &I, /*ForceVGPR*/ true);
- Register Src1Reg =
- copyToVGPRIfSrcFolded(Src1, Src1Mods, RHS, &I, /*ForceVGPR*/ true);
- SelectedMI = BuildMI(*BB, &I, DL, TII.get(Opcode), Dst)
- .addImm(Src0Mods)
- .addReg(Src0Reg)
- .addImm(Src1Mods)
- .addReg(Src1Reg)
- .addImm(0); // clamp
- } else {
- SelectedMI = BuildMI(*BB, &I, DL, TII.get(Opcode), Dst)
- .add(I.getOperand(2))
- .add(I.getOperand(3));
- }
+ MachineInstrBuilder SelectedMI;
+ MachineOperand &LHS = I.getOperand(2);
+ MachineOperand &RHS = I.getOperand(3);
+ auto [Src0, Src0Mods] = selectVOP3ModsImpl(LHS);
+ auto [Src1, Src1Mods] = selectVOP3ModsImpl(RHS);
+ Register Src0Reg =
+ copyToVGPRIfSrcFolded(Src0, Src0Mods, LHS, &I, /*ForceVGPR*/ true);
+ Register Src1Reg =
+ copyToVGPRIfSrcFolded(Src1, Src1Mods, RHS, &I, /*ForceVGPR*/ true);
+ SelectedMI = BuildMI(*BB, &I, DL, TII.get(Opcode), Dst);
+ if (AMDGPU::hasNamedOperand(Opcode, AMDGPU::OpName::src0_modifiers))
+ SelectedMI.addImm(Src0Mods);
+ SelectedMI.addReg(Src0Reg);
+ if (AMDGPU::hasNamedOperand(Opcode, AMDGPU::OpName::src1_modifiers))
+ SelectedMI.addImm(Src1Mods);
+ SelectedMI.addReg(Src1Reg);
+ if (AMDGPU::hasNamedOperand(Opcode, AMDGPU::OpName::clamp))
+ SelectedMI.addImm(0); // clamp
+ if (AMDGPU::hasNamedOperand(Opcode, AMDGPU::OpName::op_sel))
+ SelectedMI.addImm(0); // op_sel
RBI.constrainGenericRegister(Dst, *TRI.getBoolRC(), *MRI);
if (!constrainSelectedInstRegOperands(*SelectedMI, TII, TRI, RBI))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148716.514964.patch
Type: text/x-patch
Size: 2288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230419/1217331f/attachment.bin>
More information about the llvm-commits
mailing list