aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2023-06-01 16:14:02 +0100
committerFlorian Hahn <flo@fhahn.com>2023-06-01 16:14:02 +0100
commit3b912e269a52f8d30c4de38487ea8319df23f85c (patch)
tree66f37a09153ac1e61995826434a9503e87643680 /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parentcfe51dbc14b90a3fed7704a39bda215594639d2e (diff)
downloadllvm-3b912e269a52f8d30c4de38487ea8319df23f85c.zip
llvm-3b912e269a52f8d30c4de38487ea8319df23f85c.tar.gz
llvm-3b912e269a52f8d30c4de38487ea8319df23f85c.tar.bz2
[LV] Bail out on loop-variant steps when rewriting SCEV exprs.
If the step is not loop-invariant, we cannot create a modified AddRec, as the start needs to be loop-invariant. Mark those cases as CannotAnalyze and bail out, to fix a crash.
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 6934c48..7a78906e 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2569,6 +2569,10 @@ public:
// incrementing the start by Offset * step.
Type *Ty = Expr->getType();
auto *Step = Expr->getStepRecurrence(SE);
+ if (!SE.isLoopInvariant(Step, TheLoop)) {
+ CannotAnalyze = true;
+ return Expr;
+ }
auto *NewStep = SE.getMulExpr(Step, SE.getConstant(Ty, StepMultiplier));
auto *ScaledOffset = SE.getMulExpr(Step, SE.getConstant(Ty, Offset));
auto *NewStart = SE.getAddExpr(Expr->getStart(), ScaledOffset);