[llvm] [VPlan] Recognize disjoint 'or' in getSCEVExprForVPValue (PR #218405)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 01:10:00 PDT 2026
================
@@ -164,6 +164,11 @@ const SCEV *vputils::getSCEVExprForVPValue(const VPValue *V,
return CreateSCEV({LHSVal, RHSVal}, [&](ArrayRef<SCEVUse> Ops) {
return SE.getAddExpr(Ops[0], Ops[1], SCEV::FlagAnyWrap, 0);
});
+ if (match(V, m_BinaryOr(m_VPValue(LHSVal), m_VPValue(RHSVal))))
+ if (cast<VPRecipeWithIRFlags>(V->getDefiningRecipe())->isDisjoint())
+ return CreateSCEV({LHSVal, RHSVal}, [&](ArrayRef<SCEVUse> Ops) {
+ return SE.getAddExpr(Ops[0], Ops[1], SCEV::FlagNSW | SCEV::FlagNUW, 0);
----------------
Mel-Chen wrote:
As I understand it, SCEV treats 'or disjoint' and regular 'add' as the same expression during analysis. Unconditionally attaching 'nuw'/'nsw' flags to an 'add' expression derived from an 'or disjoint' could cause otherwise valid computations to be poisoned.
https://github.com/llvm/llvm-project/pull/218405
More information about the llvm-commits
mailing list