Skip to content

Commit

Permalink
[AMDGPU] Use Lo_32 and Hi_32 helpers (NFC) (#109413)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic authored Sep 20, 2024
1 parent 3127b65 commit cee0bf9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ MachineSDNode *AMDGPUDAGToDAGISel::buildSMovImm64(SDLoc &DL, uint64_t Imm,
EVT VT) const {
SDNode *Lo = CurDAG->getMachineNode(
AMDGPU::S_MOV_B32, DL, MVT::i32,
CurDAG->getTargetConstant(Imm & 0xFFFFFFFF, DL, MVT::i32));
SDNode *Hi =
CurDAG->getMachineNode(AMDGPU::S_MOV_B32, DL, MVT::i32,
CurDAG->getTargetConstant(Imm >> 32, DL, MVT::i32));
CurDAG->getTargetConstant(Lo_32(Imm), DL, MVT::i32));
SDNode *Hi = CurDAG->getMachineNode(
AMDGPU::S_MOV_B32, DL, MVT::i32,
CurDAG->getTargetConstant(Hi_32(Imm), DL, MVT::i32));
const SDValue Ops[] = {
CurDAG->getTargetConstant(AMDGPU::SReg_64RegClassID, DL, MVT::i32),
SDValue(Lo, 0), CurDAG->getTargetConstant(AMDGPU::sub0, DL, MVT::i32),
Expand Down Expand Up @@ -1805,8 +1805,8 @@ bool AMDGPUDAGToDAGISel::SelectGlobalSAddr(SDNode *N,
// single VALU instruction to materialize zero. Otherwise it is less
// instructions to perform VALU adds with immediates or inline literals.
unsigned NumLiterals =
!TII->isInlineConstant(APInt(32, COffsetVal & 0xffffffff)) +
!TII->isInlineConstant(APInt(32, COffsetVal >> 32));
!TII->isInlineConstant(APInt(32, Lo_32(COffsetVal))) +
!TII->isInlineConstant(APInt(32, Hi_32(COffsetVal)));
if (Subtarget->getConstantBusLimit(AMDGPU::V_ADD_U32_e64) > NumLiterals)
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4376,8 +4376,8 @@ AMDGPUInstructionSelector::selectGlobalSAddr(MachineOperand &Root) const {
// single VALU instruction to materialize zero. Otherwise it is less
// instructions to perform VALU adds with immediates or inline literals.
unsigned NumLiterals =
!TII.isInlineConstant(APInt(32, ConstOffset & 0xffffffff)) +
!TII.isInlineConstant(APInt(32, ConstOffset >> 32));
!TII.isInlineConstant(APInt(32, Lo_32(ConstOffset))) +
!TII.isInlineConstant(APInt(32, Hi_32(ConstOffset)));
if (STI.getConstantBusLimit(AMDGPU::V_ADD_U32_e64) > NumLiterals)
return std::nullopt;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
return;
}

Inst.addOperand(MCOperand::createImm(Val & 0xffffffff));
Inst.addOperand(MCOperand::createImm(Lo_32(Val)));
setImmKindLiteral();
return;

Expand All @@ -2421,7 +2421,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
if (isSafeTruncation(Val, 16) &&
AMDGPU::isInlinableIntLiteral(static_cast<int16_t>(Val))) {
Inst.addOperand(MCOperand::createImm(Val & 0xffffffff));
Inst.addOperand(MCOperand::createImm(Lo_32(Val)));
setImmKindConst();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/GCNPreRAOptimizations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool GCNPreRAOptimizations::processReg(Register Reg) {
if (Def0)
return false;
Def0 = &I;
Init |= I.getOperand(1).getImm() & 0xffffffff;
Init |= Lo_32(I.getOperand(1).getImm());
break;
case AMDGPU::sub1:
if (Def1)
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,12 @@ void SIFrameLowering::emitEntryFunctionScratchRsrcRegSetup(
}

BuildMI(MBB, I, DL, SMovB32, Rsrc2)
.addImm(Rsrc23 & 0xffffffff)
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
.addImm(Lo_32(Rsrc23))
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);

BuildMI(MBB, I, DL, SMovB32, Rsrc3)
.addImm(Rsrc23 >> 32)
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
.addImm(Hi_32(Rsrc23))
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
} else if (ST.isAmdHsaOrMesa(Fn)) {
assert(PreloadedScratchRsrcReg);

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6554,11 +6554,11 @@ extractRsrcPtr(const SIInstrInfo &TII, MachineInstr &MI, MachineOperand &Rsrc) {

// SRsrcFormatLo = RSRC_DATA_FORMAT{31-0}
BuildMI(MBB, MI, MI.getDebugLoc(), TII.get(AMDGPU::S_MOV_B32), SRsrcFormatLo)
.addImm(RsrcDataFormat & 0xFFFFFFFF);
.addImm(Lo_32(RsrcDataFormat));

// SRsrcFormatHi = RSRC_DATA_FORMAT{63-32}
BuildMI(MBB, MI, MI.getDebugLoc(), TII.get(AMDGPU::S_MOV_B32), SRsrcFormatHi)
.addImm(RsrcDataFormat >> 32);
.addImm(Hi_32(RsrcDataFormat));

// NewSRsrc = {Zero64, SRsrcFormat}
BuildMI(MBB, MI, MI.getDebugLoc(), TII.get(AMDGPU::REG_SEQUENCE), NewSRsrc)
Expand Down

0 comments on commit cee0bf9

Please sign in to comment.