Skip to content

Commit cee0bf9

Browse files
authored
[AMDGPU] Use Lo_32 and Hi_32 helpers (NFC) (#109413)
1 parent 3127b65 commit cee0bf9

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ MachineSDNode *AMDGPUDAGToDAGISel::buildSMovImm64(SDLoc &DL, uint64_t Imm,
424424
EVT VT) const {
425425
SDNode *Lo = CurDAG->getMachineNode(
426426
AMDGPU::S_MOV_B32, DL, MVT::i32,
427-
CurDAG->getTargetConstant(Imm & 0xFFFFFFFF, DL, MVT::i32));
428-
SDNode *Hi =
429-
CurDAG->getMachineNode(AMDGPU::S_MOV_B32, DL, MVT::i32,
430-
CurDAG->getTargetConstant(Imm >> 32, DL, MVT::i32));
427+
CurDAG->getTargetConstant(Lo_32(Imm), DL, MVT::i32));
428+
SDNode *Hi = CurDAG->getMachineNode(
429+
AMDGPU::S_MOV_B32, DL, MVT::i32,
430+
CurDAG->getTargetConstant(Hi_32(Imm), DL, MVT::i32));
431431
const SDValue Ops[] = {
432432
CurDAG->getTargetConstant(AMDGPU::SReg_64RegClassID, DL, MVT::i32),
433433
SDValue(Lo, 0), CurDAG->getTargetConstant(AMDGPU::sub0, DL, MVT::i32),
@@ -1805,8 +1805,8 @@ bool AMDGPUDAGToDAGISel::SelectGlobalSAddr(SDNode *N,
18051805
// single VALU instruction to materialize zero. Otherwise it is less
18061806
// instructions to perform VALU adds with immediates or inline literals.
18071807
unsigned NumLiterals =
1808-
!TII->isInlineConstant(APInt(32, COffsetVal & 0xffffffff)) +
1809-
!TII->isInlineConstant(APInt(32, COffsetVal >> 32));
1808+
!TII->isInlineConstant(APInt(32, Lo_32(COffsetVal))) +
1809+
!TII->isInlineConstant(APInt(32, Hi_32(COffsetVal)));
18101810
if (Subtarget->getConstantBusLimit(AMDGPU::V_ADD_U32_e64) > NumLiterals)
18111811
return false;
18121812
}

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4376,8 +4376,8 @@ AMDGPUInstructionSelector::selectGlobalSAddr(MachineOperand &Root) const {
43764376
// single VALU instruction to materialize zero. Otherwise it is less
43774377
// instructions to perform VALU adds with immediates or inline literals.
43784378
unsigned NumLiterals =
4379-
!TII.isInlineConstant(APInt(32, ConstOffset & 0xffffffff)) +
4380-
!TII.isInlineConstant(APInt(32, ConstOffset >> 32));
4379+
!TII.isInlineConstant(APInt(32, Lo_32(ConstOffset))) +
4380+
!TII.isInlineConstant(APInt(32, Hi_32(ConstOffset)));
43814381
if (STI.getConstantBusLimit(AMDGPU::V_ADD_U32_e64) > NumLiterals)
43824382
return std::nullopt;
43834383
}

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
23942394
return;
23952395
}
23962396

2397-
Inst.addOperand(MCOperand::createImm(Val & 0xffffffff));
2397+
Inst.addOperand(MCOperand::createImm(Lo_32(Val)));
23982398
setImmKindLiteral();
23992399
return;
24002400

@@ -2421,7 +2421,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
24212421
case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
24222422
if (isSafeTruncation(Val, 16) &&
24232423
AMDGPU::isInlinableIntLiteral(static_cast<int16_t>(Val))) {
2424-
Inst.addOperand(MCOperand::createImm(Val & 0xffffffff));
2424+
Inst.addOperand(MCOperand::createImm(Lo_32(Val)));
24252425
setImmKindConst();
24262426
return;
24272427
}

llvm/lib/Target/AMDGPU/GCNPreRAOptimizations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ bool GCNPreRAOptimizations::processReg(Register Reg) {
159159
if (Def0)
160160
return false;
161161
Def0 = &I;
162-
Init |= I.getOperand(1).getImm() & 0xffffffff;
162+
Init |= Lo_32(I.getOperand(1).getImm());
163163
break;
164164
case AMDGPU::sub1:
165165
if (Def1)

llvm/lib/Target/AMDGPU/SIFrameLowering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,12 @@ void SIFrameLowering::emitEntryFunctionScratchRsrcRegSetup(
829829
}
830830

831831
BuildMI(MBB, I, DL, SMovB32, Rsrc2)
832-
.addImm(Rsrc23 & 0xffffffff)
833-
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
832+
.addImm(Lo_32(Rsrc23))
833+
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
834834

835835
BuildMI(MBB, I, DL, SMovB32, Rsrc3)
836-
.addImm(Rsrc23 >> 32)
837-
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
836+
.addImm(Hi_32(Rsrc23))
837+
.addReg(ScratchRsrcReg, RegState::ImplicitDefine);
838838
} else if (ST.isAmdHsaOrMesa(Fn)) {
839839
assert(PreloadedScratchRsrcReg);
840840

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6554,11 +6554,11 @@ extractRsrcPtr(const SIInstrInfo &TII, MachineInstr &MI, MachineOperand &Rsrc) {
65546554

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

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

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

0 commit comments

Comments
 (0)