[llvm] [VPlan] Implement VPlan-based unit-strideness speculation (PR #182595)
Andrei Elovikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 09:02:03 PDT 2026
================
@@ -5520,6 +5529,183 @@ void VPlanTransforms::makeMemOpWideningDecisions(VPlan &Plan, VFRange &Range,
});
}
+void VPlanTransforms::multiversionForUnitStridedMemOps(
+ VPlan &Plan, VPCostContext &CostCtx, VFRange &Range,
+ ArrayRef<VPInstruction *> MemOps) {
+ ScalarEvolution *SE = CostCtx.PSE.getSE();
+ SCEVUnionPredicate StridePredicates({}, *SE);
+
+ for (VPInstruction *VPI : MemOps) {
+ VPValue *PtrOp = VPI->getOpcode() == Instruction::Load ? VPI->getOperand(0)
+ : VPI->getOperand(1);
+
+ const SCEV *PtrSCEV =
+ vputils::getSCEVExprForVPValue(PtrOp, CostCtx.PSE, CostCtx.L);
+ const SCEV *Start, *Stride;
+
+ if (!match(PtrSCEV, m_scev_AffineAddRec(m_SCEV(Start), m_SCEV(Stride),
+ m_SpecificLoop(CostCtx.L))))
+ continue;
+
+ Type *ScalarTy = VPI->getOpcode() == Instruction::Load
+ ? VPI->getScalarType()
+ : VPI->getOperand(0)->getScalarType();
+
+ if (VPI->getMask()) {
+ Instruction *I = VPI->getUnderlyingInstr();
+ bool IsLoad = VPI->getOpcode() == Instruction::Load;
----------------
eas wrote:
Done
https://github.com/llvm/llvm-project/pull/182595
More information about the llvm-commits
mailing list