[llvm] [VPlan] Recognize disjoint 'or' in getSCEVExprForVPValue (PR #218405)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 02:58:33 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);
----------------
lukel97 wrote:

Why wouldn't it be valid to add the flags? If the inputs aren't disjoint then it's poison, so we can transform it to whatever. If they are disjoint they won't unsigned or signed wrap, so we can add the flags. https://alive2.llvm.org/ce/z/gB34kE

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


More information about the llvm-commits mailing list