Skip to content

Commit 2db2dc8

Browse files
authored
[GlobalISel][NFC] Fix LLT Propagation (#119587)
Retain LLT type information by creating new LLTs from the original LLT instead of only using the original scalar size. This PR prepares for the [LLT FPInfo RFC](https://discourse.llvm.org/t/rfc-globalisel-adding-fp-type-information-to-llt/83349/24) where LLTs will carry additional floating point type information in addition to the scalar size.
1 parent 357d00d commit 2db2dc8

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5347,9 +5347,9 @@ LegalizerHelper::fewerElementsBitcast(MachineInstr &MI, unsigned int TypeIdx,
53475347

53485348
auto [DstReg, DstTy, SrcReg, SrcTy] = MI.getFirst2RegLLTs();
53495349

5350-
unsigned SrcScalSize = SrcTy.getScalarSizeInBits();
5351-
LLT SrcNarrowTy =
5352-
LLT::fixed_vector(NarrowTy.getSizeInBits() / SrcScalSize, SrcScalSize);
5350+
unsigned NewElemCount =
5351+
NarrowTy.getSizeInBits() / SrcTy.getScalarSizeInBits();
5352+
LLT SrcNarrowTy = LLT::fixed_vector(NewElemCount, SrcTy.getElementType());
53535353

53545354
// Split the Src and Dst Reg into smaller registers
53555355
SmallVector<Register> SrcVRegs, BitcastVRegs;

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,7 @@ bool llvm::extractParts(Register Reg, LLT RegTy, LLT MainTy, LLT &LeftoverTy,
525525
RegNumElts % LeftoverNumElts == 0 &&
526526
RegTy.getScalarSizeInBits() == MainTy.getScalarSizeInBits() &&
527527
LeftoverNumElts > 1) {
528-
LeftoverTy =
529-
LLT::fixed_vector(LeftoverNumElts, RegTy.getScalarSizeInBits());
528+
LeftoverTy = LLT::fixed_vector(LeftoverNumElts, RegTy.getElementType());
530529

531530
// Unmerge the SrcReg to LeftoverTy vectors
532531
SmallVector<Register, 4> UnmergeValues;

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ static LegalizeMutation moreElementsToNextExistingRegClass(unsigned TypeIdx) {
154154
if (SIRegisterInfo::getSGPRClassForBitWidth(NewNumElts * EltSize))
155155
break;
156156
}
157-
158-
return std::pair(TypeIdx, LLT::fixed_vector(NewNumElts, EltSize));
157+
return std::pair(TypeIdx,
158+
LLT::fixed_vector(NewNumElts, Ty.getElementType()));
159159
};
160160
}
161161

0 commit comments

Comments
 (0)