[llvm] Vectorize ld st nop (PR #223412)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 02:19:49 PDT 2026
================
@@ -3996,6 +3996,177 @@ void VPlanTransforms::sinkPredicatedStores(VPlan &Plan,
}
}
+/// Return the recipe defining \p V if it is an unpredicated GEP with an
+/// underlying GetElementPtrInst, i.e. a VPWidenGEPRecipe or a replicating GEP.
+static VPRecipeWithIRFlags *getGEPRecipe(VPValue *V) {
+ auto *R = dyn_cast_or_null<VPRecipeWithIRFlags>(V->getDefiningRecipe());
+ if (!R)
+ return nullptr;
+ if (isa<VPWidenGEPRecipe>(R))
+ return R;
+ auto *RepR = dyn_cast<VPReplicateRecipe>(R);
+ if (RepR && RepR->getOpcode() == Instruction::GetElementPtr &&
+ !RepR->isPredicated())
+ return RepR;
+ return nullptr;
+}
+
+/// Return true if \p A and \p B are GEPs with loop-invariant base pointers
+/// that only differ in their base pointer, i.e. they compute addresses with the
+/// same stride.
+static bool areGEPsWithSameIndices(VPRecipeWithIRFlags *A,
+ VPRecipeWithIRFlags *B) {
+ auto *GEPA = cast<GetElementPtrInst>(A->getUnderlyingInstr());
+ auto *GEPB = cast<GetElementPtrInst>(B->getUnderlyingInstr());
+ if (GEPA->getSourceElementType() != GEPB->getSourceElementType() ||
+ A->getNumOperands() != B->getNumOperands())
+ return false;
+ if (!A->getOperand(0)->isDefinedOutsideLoopRegions() ||
+ !B->getOperand(0)->isDefinedOutsideLoopRegions())
+ return false;
+ return std::equal(std::next(A->op_begin()), A->op_end(),
+ std::next(B->op_begin()));
+}
+
+void VPlanTransforms::convertSelectPtrLoadStoreToMasked(VPlan &Plan) {
----------------
fhahn wrote:
I'd expect this needs to be cost-driven, masked loads/stores are not profitable/available on all architectures
https://github.com/llvm/llvm-project/pull/223412
More information about the llvm-commits
mailing list