Skip to content

Commit f4087f6

Browse files
authored
[AMDGPU] Fix op_sel settings for v_cvt_scale32_* and v_cvt_sr_* (llvm#151286) (llvm#3385)
2 parents 06da02d + fbc93e3 commit f4087f6

File tree

3 files changed

+49
-46
lines changed

3 files changed

+49
-46
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6133,13 +6133,13 @@ void AMDGPUInstructionSelector::renderSrcAndDstSelToOpSelXForm_0_0(
61336133
MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
61346134
assert(OpIdx >= 0 && "expected to match an immediate operand");
61356135
MIB.addImm(
6136-
(MI.getOperand(OpIdx).getImm() & 0x2) ? (int64_t)SISrcMods::OP_SEL_0 : 0);
6136+
(MI.getOperand(OpIdx).getImm() & 0x1) ? (int64_t)SISrcMods::OP_SEL_0 : 0);
61376137
}
61386138

61396139
void AMDGPUInstructionSelector::renderSrcAndDstSelToOpSelXForm_0_1(
61406140
MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
61416141
assert(OpIdx >= 0 && "expected to match an immediate operand");
6142-
MIB.addImm((MI.getOperand(OpIdx).getImm() & 0x2)
6142+
MIB.addImm((MI.getOperand(OpIdx).getImm() & 0x1)
61436143
? (int64_t)(SISrcMods::OP_SEL_0 | SISrcMods::DST_OP_SEL)
61446144
: (int64_t)SISrcMods::DST_OP_SEL);
61456145
}
@@ -6148,13 +6148,13 @@ void AMDGPUInstructionSelector::renderSrcAndDstSelToOpSelXForm_1_0(
61486148
MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
61496149
assert(OpIdx >= 0 && "expected to match an immediate operand");
61506150
MIB.addImm(
6151-
(MI.getOperand(OpIdx).getImm() & 0x1) ? (int64_t)SISrcMods::OP_SEL_0 : 0);
6151+
(MI.getOperand(OpIdx).getImm() & 0x2) ? (int64_t)SISrcMods::OP_SEL_0 : 0);
61526152
}
61536153

61546154
void AMDGPUInstructionSelector::renderSrcAndDstSelToOpSelXForm_1_1(
61556155
MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
61566156
assert(OpIdx >= 0 && "expected to match an immediate operand");
6157-
MIB.addImm((MI.getOperand(OpIdx).getImm() & 0x1)
6157+
MIB.addImm((MI.getOperand(OpIdx).getImm() & 0x2)
61586158
? (int64_t)(SISrcMods::OP_SEL_0)
61596159
: 0);
61606160
}
@@ -6183,8 +6183,9 @@ void AMDGPUInstructionSelector::renderSrcAndDstSelToOpSelXForm_2_0(
61836183
void AMDGPUInstructionSelector::renderDstSelToOpSel3XFormXForm(
61846184
MachineInstrBuilder &MIB, const MachineInstr &MI, int OpIdx) const {
61856185
assert(OpIdx >= 0 && "expected to match an immediate operand");
6186-
MIB.addImm(
6187-
(MI.getOperand(OpIdx).getImm() & 0x2) ? (int64_t)SISrcMods::DST_OP_SEL : 0);
6186+
MIB.addImm((MI.getOperand(OpIdx).getImm() & 0x2)
6187+
? (int64_t)SISrcMods::DST_OP_SEL
6188+
: 0);
61886189
}
61896190

61906191
void AMDGPUInstructionSelector::renderExtractCPol(MachineInstrBuilder &MIB,

llvm/lib/Target/AMDGPU/VOP3Instructions.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,12 @@ class SrcAndDstSelToOpSelXForm<int modifier_idx, bit dest_sel> : SDNodeXForm<tim
861861
unsigned Val = N->getZExtValue();
862862
unsigned New = 0;
863863
if (}] # modifier_idx # [{ == 0) {
864-
New = (}] # dest_sel # [{ == 1) ? ((Val & 0x2) ? (SISrcMods::OP_SEL_0 | SISrcMods::DST_OP_SEL) : SISrcMods::DST_OP_SEL)
865-
: ((Val & 0x2) ? SISrcMods::OP_SEL_0 : SISrcMods::NONE);
866-
} else if (}] # modifier_idx # [{== 1 || }] # modifier_idx # [{ == 2) {
867-
New = (Val & 0x1) ? SISrcMods::OP_SEL_0 : SISrcMods::NONE;
864+
New = (}] # dest_sel # [{ == 1) ? ((Val & 0x1) ? (SISrcMods::OP_SEL_0 | SISrcMods::DST_OP_SEL) : SISrcMods::DST_OP_SEL)
865+
: ((Val & 0x1) ? SISrcMods::OP_SEL_0 : SISrcMods::NONE);
866+
} else if (}] # modifier_idx # [{== 1) {
867+
New = (Val & 0x2) ? SISrcMods::OP_SEL_0 : SISrcMods::NONE;
868+
} if (}] # modifier_idx # [{== 2) {
869+
New = (Val & 0x1) ? SISrcMods::OP_SEL_0 : SISrcMods::NONE;
868870
}
869871
return CurDAG->getTargetConstant(New, SDLoc(N), MVT::i32);
870872
}]>;

0 commit comments

Comments
 (0)