Skip to content

Commit

Permalink
[AMDGPU] Preserve src2_modifiers in convertToThreeAddress
Browse files Browse the repository at this point in the history
Found by code inspection. I don't think it makes a difference with
current codegen, because if any source modifiers were present we
would have selected mad/fma instead of mac/fmac in the first place.

Differential Revision: https://reviews.llvm.org/D120709
  • Loading branch information
jayfoad committed Mar 1, 2022
1 parent a968bee commit 6889509
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Expand Up @@ -3289,10 +3289,12 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI,
const MachineOperand *Src1Mods =
getNamedOperand(MI, AMDGPU::OpName::src1_modifiers);
const MachineOperand *Src2 = getNamedOperand(MI, AMDGPU::OpName::src2);
const MachineOperand *Src2Mods =
getNamedOperand(MI, AMDGPU::OpName::src2_modifiers);
const MachineOperand *Clamp = getNamedOperand(MI, AMDGPU::OpName::clamp);
const MachineOperand *Omod = getNamedOperand(MI, AMDGPU::OpName::omod);

if (!Src0Mods && !Src1Mods && !Clamp && !Omod && !IsF64 &&
if (!Src0Mods && !Src1Mods && !Src2Mods && !Clamp && !Omod && !IsF64 &&
// If we have an SGPR input, we will violate the constant bus restriction.
(ST.getConstantBusLimit(Opc) > 1 || !Src0->isReg() ||
!RI.isSGPRReg(MBB.getParent()->getRegInfo(), Src0->getReg()))) {
Expand Down Expand Up @@ -3375,7 +3377,7 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI,
.add(*Src0)
.addImm(Src1Mods ? Src1Mods->getImm() : 0)
.add(*Src1)
.addImm(0) // Src mods
.addImm(Src2Mods ? Src2Mods->getImm() : 0)
.add(*Src2)
.addImm(Clamp ? Clamp->getImm() : 0)
.addImm(Omod ? Omod->getImm() : 0);
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/AMDGPU/twoaddr-fma.mir
Expand Up @@ -297,9 +297,8 @@ body: |
%3:vgpr_32 = V_FMAC_F32_e64 0, %0, 1, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
...

# FIXME: Preserve src2_modifiers
# GCN-LABEL: name: test_fma_src2mods
# GCN: %3:vgpr_32 = V_FMA_F32_e64 0, %0, 0, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
# GCN: %3:vgpr_32 = V_FMA_F32_e64 0, %0, 0, %1, 1, %2, 0, 0, implicit $mode, implicit $exec
---
name: test_fma_src2mods
body: |
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/AMDGPU/twoaddr-mad.mir
Expand Up @@ -232,9 +232,8 @@ body: |
%3:vgpr_32 = V_MAC_F32_e64 0, %0, 1, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
...

# FIXME: Preserve src2_modifiers
# GCN-LABEL: name: test_mad_src2mods
# GCN: %3:vgpr_32 = V_MAD_F32_e64 0, %0, 0, %1, 0, %2, 0, 0, implicit $mode, implicit $exec
# GCN: %3:vgpr_32 = V_MAD_F32_e64 0, %0, 0, %1, 1, %2, 0, 0, implicit $mode, implicit $exec
---
name: test_mad_src2mods
body: |
Expand Down

0 comments on commit 6889509

Please sign in to comment.