[llvm] [VectorCombine][AMDGPU] Shrink demanded vector loads (PR #202501)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 02:05:48 PDT 2026


================
@@ -2157,6 +2160,231 @@ bool VectorCombine::scalarizeLoadExtract(LoadInst *LI, VectorType *VecTy,
   return true;
 }
 
+/// Try to shrink vector loads feeding extractelement instructions when some
+/// of the loaded lanes are not demanded.
+bool VectorCombine::shrinkLoadForExtracts(Instruction &I) {
+  if (!DB)
+    return false;
+
+  auto *OldLoad = dyn_cast<LoadInst>(&I);
+  if (!OldLoad || !OldLoad->isSimple())
+    return false;
+
+  auto *OldLoadTy = dyn_cast<FixedVectorType>(OldLoad->getType());
+  if (!OldLoadTy)
+    return false;
+
+  Type *OldEltTy = OldLoadTy->getElementType();
+  bool IsIntegerElement = OldEltTy->isIntegerTy();
+  bool IsFloatingPointElement = OldEltTy->isFloatingPointTy();
+  if (!IsIntegerElement && !IsFloatingPointElement)
+    return false;
----------------
arsenm wrote:

should be able to handle any element type? 

https://github.com/llvm/llvm-project/pull/202501


More information about the llvm-commits mailing list