Skip to content

WIP: AMDGPU: Implement getRegSequenceLikeInputs for v_pk_mov_b32 #125657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9725,6 +9725,40 @@ MachineInstr *SIInstrInfo::foldMemoryOperandImpl(
return nullptr;
}

bool SIInstrInfo::getRegSequenceLikeInputs(
const MachineInstr &MI, unsigned DefIdx,
SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const {
assert(MI.getOpcode() == AMDGPU::V_PK_MOV_B32 &&
"v_pk_mov_b32 is the only reg-sequence like instruction");
assert(DefIdx == 0);

unsigned Src0Mods = MI.getOperand(1).getImm();
const MachineOperand &Src0 = MI.getOperand(2);
unsigned Src1Mods = MI.getOperand(3).getImm();
const MachineOperand &Src1 = MI.getOperand(4);

unsigned SubReg0 =
Src0Mods & SISrcMods::OP_SEL_0 ? AMDGPU::sub1 : AMDGPU::sub0;
unsigned SubReg1 =
Src1Mods & SISrcMods::OP_SEL_0 ? AMDGPU::sub1 : AMDGPU::sub0;

if (!Src0.isUndef()) {
// src0 will provide the result sub0 from src0.
SubReg0 = RI.composeSubRegIndices(Src0.getSubReg(), SubReg0);
InputRegs.push_back(
RegSubRegPairAndIdx(Src0.getReg(), SubReg0, AMDGPU::sub0));
}

if (!Src1.isUndef()) {
// src1 will provide the result's sub1 from src1.
SubReg1 = RI.composeSubRegIndices(Src1.getSubReg(), SubReg1);
InputRegs.push_back(
RegSubRegPairAndIdx(Src1.getReg(), SubReg1, AMDGPU::sub1));
}

return true;
}

unsigned SIInstrInfo::getInstrLatency(const InstrItineraryData *ItinData,
const MachineInstr &MI,
unsigned *PredCost) const {
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,9 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
int FrameIndex,
LiveIntervals *LIS = nullptr,
VirtRegMap *VRM = nullptr) const override;
bool getRegSequenceLikeInputs(
const MachineInstr &MI, unsigned DefIdx,
SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const override;

unsigned getInstrLatency(const InstrItineraryData *ItinData,
const MachineInstr &MI,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/VOP3PInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ let isCommutable = 1, isReMaterializable = 1 in {
defm V_PK_ADD_F32 : VOP3PInst<"v_pk_add_f32", VOP3P_Profile<VOP_V2F32_V2F32_V2F32, VOP3_PACKED>, any_fadd>;
} // End SubtargetPredicate = HasPackedFP32Ops

let SubtargetPredicate = HasPkMovB32 in
let SubtargetPredicate = HasPkMovB32, isRegSequence = 1 in
defm V_PK_MOV_B32 : VOP3PInst<"v_pk_mov_b32", VOP3P_Profile<VOP_V2I32_V2I32_V2I32, VOP3_PACKED>>;
} // End isCommutable = 1, isReMaterializable = 1

Expand Down
413 changes: 413 additions & 0 deletions llvm/test/CodeGen/AMDGPU/reg-sequence-like-v-pk-mov-b32.mir

Large diffs are not rendered by default.

Loading