[llvm] [VectorCombine] Try to scalarize vector loads feeding bitcast instructions. (PR #164682)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 6 03:07:06 PST 2025


================
@@ -1899,6 +1894,35 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
       }
       LastCheckedInst = UI;
     }
+  }
+
+  if (AllExtracts)
+    return scalarizeLoadExtract(LI, VecTy, Ptr);
+  if (AllBitcasts)
+    return scalarizeLoadBitcast(LI, VecTy, Ptr);
+  return false;
+}
+
+/// Try to scalarize vector loads feeding extractelement instructions.
+bool VectorCombine::scalarizeLoadExtract(LoadInst *LI, VectorType *VecTy,
+                                         Value *Ptr) {
+  if (!TTI.allowVectorElementIndexingUsingGEP())
+    return false;
+
+  InstructionCost OriginalCost =
+      TTI.getMemoryOpCost(Instruction::Load, VecTy, LI->getAlign(),
+                          LI->getPointerAddressSpace(), CostKind);
+  InstructionCost ScalarizedCost = 0;
----------------
fhahn wrote:

Can sink this after the FailGuard, closer to the loop that sets them

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


More information about the llvm-commits mailing list