Skip to content

Commit c875417

Browse files
committed
[GlobalIsel][NFC] fix LLT propagation
Retain LLT type information by creating new LLTs from the original LLT instead of only using the original scalar size.
1 parent 323bedd commit c875417

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5347,9 +5347,8 @@ 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 = NarrowTy.getSizeInBits() / SrcTy.getScalarSizeInBits();
5351+
LLT SrcNarrowTy = LLT::fixed_vector(NewElemCount, SrcTy.getElementType());
53535352

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

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ bool llvm::extractParts(Register Reg, LLT RegTy, LLT MainTy, LLT &LeftoverTy,
526526
RegTy.getScalarSizeInBits() == MainTy.getScalarSizeInBits() &&
527527
LeftoverNumElts > 1) {
528528
LeftoverTy =
529-
LLT::fixed_vector(LeftoverNumElts, RegTy.getScalarSizeInBits());
529+
LLT::fixed_vector(LeftoverNumElts, RegTy.getElementType());
530530

531531
// Unmerge the SrcReg to LeftoverTy vectors
532532
SmallVector<Register, 4> UnmergeValues;

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ 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, LLT::fixed_vector(NewNumElts, Ty.getElementType()));
159158
};
160159
}
161160

0 commit comments

Comments
 (0)