[llvm] [GlobalIsel][NFC] Fix LLT Propagation (PR #119587)
Tim Gymnich via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 08:59:52 PST 2024
https://github.com/tgymnich updated https://github.com/llvm/llvm-project/pull/119587
>From 71509ea604febe4cae5f9fa27c4e478323a03a80 Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tim at gymni.ch>
Date: Thu, 24 Oct 2024 09:32:12 +0000
Subject: [PATCH] [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.
---
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 6 +++---
llvm/lib/CodeGen/GlobalISel/Utils.cpp | 3 +--
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 4 ++--
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index f56be39838ba7d..83c1d79b1f92dd 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -5347,9 +5347,9 @@ LegalizerHelper::fewerElementsBitcast(MachineInstr &MI, unsigned int TypeIdx,
auto [DstReg, DstTy, SrcReg, SrcTy] = MI.getFirst2RegLLTs();
- unsigned SrcScalSize = SrcTy.getScalarSizeInBits();
- LLT SrcNarrowTy =
- LLT::fixed_vector(NarrowTy.getSizeInBits() / SrcScalSize, SrcScalSize);
+ unsigned NewElemCount =
+ NarrowTy.getSizeInBits() / SrcTy.getScalarSizeInBits();
+ LLT SrcNarrowTy = LLT::fixed_vector(NewElemCount, SrcTy.getElementType());
// Split the Src and Dst Reg into smaller registers
SmallVector<Register> SrcVRegs, BitcastVRegs;
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 45807a6818ee5e..8c1e41ea106eca 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -525,8 +525,7 @@ bool llvm::extractParts(Register Reg, LLT RegTy, LLT MainTy, LLT &LeftoverTy,
RegNumElts % LeftoverNumElts == 0 &&
RegTy.getScalarSizeInBits() == MainTy.getScalarSizeInBits() &&
LeftoverNumElts > 1) {
- LeftoverTy =
- LLT::fixed_vector(LeftoverNumElts, RegTy.getScalarSizeInBits());
+ LeftoverTy = LLT::fixed_vector(LeftoverNumElts, RegTy.getElementType());
// Unmerge the SrcReg to LeftoverTy vectors
SmallVector<Register, 4> UnmergeValues;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 2e66f7525b9ccf..9836e10c36bc5d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -154,8 +154,8 @@ static LegalizeMutation moreElementsToNextExistingRegClass(unsigned TypeIdx) {
if (SIRegisterInfo::getSGPRClassForBitWidth(NewNumElts * EltSize))
break;
}
-
- return std::pair(TypeIdx, LLT::fixed_vector(NewNumElts, EltSize));
+ return std::pair(TypeIdx,
+ LLT::fixed_vector(NewNumElts, Ty.getElementType()));
};
}
More information about the llvm-commits
mailing list