[llvm] [SCEV] Require that addrec operands dominate the loop (PR #67030)

Danila Malyutin via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 09:06:19 PDT 2023


================
@@ -3670,9 +3670,12 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
            "SCEVAddRecExpr operand types don't match!");
     assert(!Operands[i]->getType()->isPointerTy() && "Step must be integer");
   }
-  for (unsigned i = 0, e = Operands.size(); i != e; ++i)
+  for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
     assert(isLoopInvariant(Operands[i], L) &&
            "SCEVAddRecExpr operand is not loop-invariant!");
+    assert(properlyDominates(Operands[i], L->getHeader()) &&
----------------
danilaml wrote:

I've found a case where this change now triggers this assert after loop unswitching (in SCEV verify that was enabled via expensive checks but could be triggered latter if run without them). Trying to create a small repro, but not sure if I manage to do so since it depends on a lot of transient state (like analyses) in a loop pass manager.

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


More information about the llvm-commits mailing list