[llvm] [InstCombine] Fold variable extract of a constant-strided pointer vector (PR #217078)
Domenic Nutile via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 10:32:45 PDT 2026
================
@@ -410,6 +410,83 @@ static ConstantInt *getPreferredVectorIndex(ConstantInt *IndexC) {
IndexC->getValue().zextOrTrunc(64));
}
+/// Fold a variable extract from a vector of pointers that all point into the
+/// same object at a constant stride
+static Value *
+foldExtractOfStridedPointerVector(ExtractElementInst &EI,
+ InstCombiner::BuilderTy &Builder,
+ const DataLayout &DL) {
+ auto *VecTy = dyn_cast<FixedVectorType>(EI.getVectorOperandType());
+ if (!VecTy || !VecTy->getElementType()->isPointerTy())
+ return nullptr;
+
+ unsigned NumElts = VecTy->getNumElements();
+ if (NumElts < 2)
+ return nullptr;
+
+ // Walk the insertelement chain outermost-first, so the first value seen for
+ // an index is the one that survives
+ SmallVector<Value *> Elts(NumElts, nullptr);
----------------
saxlungs wrote:
Good call, I switched to using findScalarElement instead
https://github.com/llvm/llvm-project/pull/217078
More information about the llvm-commits
mailing list