[llvm] [SCEV] Return a SCEVUse from getAddExpr and propagate use flags. (PR #220007)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 04:28:51 PDT 2026


================
@@ -3002,7 +2985,11 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<SCEVUse> &Ops,
 
   // Okay, it looks like we really DO need an add expr.  Check to see if we
   // already have one, otherwise create a new one.
-  return getOrCreateAddExpr(Ops, ComputeFlags(Ops));
+  assert((UseFlags == SCEV::FlagAnyWrap ||
+          std::is_permutation(OrigOps.begin(), OrigOps.end(), Ops.begin(),
+                              Ops.end())) &&
----------------
nikic wrote:

Do we actually need is_permutation here? Is something reordering the operands (after complexity sorting)?

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


More information about the llvm-commits mailing list