[llvm] [SCEV] Require that addrec operands dominate the loop (PR #67030)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 11:07:16 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()) &&
----------------
preames wrote:
I find it quite surprising that a value defined after L (i.e. whose live range doesn't include L) is consider loop invariant in L. I wonder if we don't have a whole class of bugs based on that confusion - i.e. beyond this single change.
Do you have any example of a case where we create a SCEV with operands defined after the defining scope of the SCEV?
https://github.com/llvm/llvm-project/pull/67030
More information about the llvm-commits
mailing list