Skip to content

Commit a1edb1d

Browse files
authored
[AMDGPU] Fix broken uses of isLegalFLATOffset and splitFlatOffset (#147469)
The last parameter of these functions used to be `Signed`, and it looks like a few calls weren't updated when that was changed to `FlatVariant`. Effectively, the functions were called with `FlatVariant=SALU` due to integer promotions, which doesn't make any sense.
1 parent df6ae45 commit a1edb1d

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,16 +2032,17 @@ bool AMDGPUDAGToDAGISel::SelectScratchSVAddr(SDNode *N, SDValue Addr,
20322032
int64_t COffsetVal = cast<ConstantSDNode>(RHS)->getSExtValue();
20332033
const SIInstrInfo *TII = Subtarget->getInstrInfo();
20342034

2035-
if (TII->isLegalFLATOffset(COffsetVal, AMDGPUAS::PRIVATE_ADDRESS, true)) {
2035+
if (TII->isLegalFLATOffset(COffsetVal, AMDGPUAS::PRIVATE_ADDRESS,
2036+
SIInstrFlags::FlatScratch)) {
20362037
Addr = LHS;
20372038
ImmOffset = COffsetVal;
20382039
} else if (!LHS->isDivergent() && COffsetVal > 0) {
20392040
SDLoc SL(N);
20402041
// saddr + large_offset -> saddr + (vaddr = large_offset & ~MaxOffset) +
20412042
// (large_offset & MaxOffset);
20422043
int64_t SplitImmOffset, RemainderOffset;
2043-
std::tie(SplitImmOffset, RemainderOffset)
2044-
= TII->splitFlatOffset(COffsetVal, AMDGPUAS::PRIVATE_ADDRESS, true);
2044+
std::tie(SplitImmOffset, RemainderOffset) = TII->splitFlatOffset(
2045+
COffsetVal, AMDGPUAS::PRIVATE_ADDRESS, SIInstrFlags::FlatScratch);
20452046

20462047
if (isUInt<32>(RemainderOffset)) {
20472048
SDNode *VMov = CurDAG->getMachineNode(

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5591,7 +5591,8 @@ AMDGPUInstructionSelector::selectScratchSVAddr(MachineOperand &Root) const {
55915591

55925592
Register OrigAddr = Addr;
55935593
if (ConstOffset != 0 &&
5594-
TII.isLegalFLATOffset(ConstOffset, AMDGPUAS::PRIVATE_ADDRESS, true)) {
5594+
TII.isLegalFLATOffset(ConstOffset, AMDGPUAS::PRIVATE_ADDRESS,
5595+
SIInstrFlags::FlatScratch)) {
55955596
Addr = PtrBase;
55965597
ImmOffset = ConstOffset;
55975598
}

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
14481448
Align Alignment = Align(4)) const;
14491449

14501450
/// Returns if \p Offset is legal for the subtarget as the offset to a FLAT
1451-
/// encoded instruction. If \p Signed, this is for an instruction that
1452-
/// interprets the offset as signed.
1451+
/// encoded instruction with the given \p FlatVariant.
14531452
bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace,
14541453
uint64_t FlatVariant) const;
14551454

0 commit comments

Comments
 (0)