Skip to content

Commit

Permalink
[IndVars] Speculative fix for an assertion failure seen in bots
Browse files Browse the repository at this point in the history
I don't have an IR sample which is actually failing, but the issue described in the comment is theoretically possible, and should be guarded against even if there's a different root cause for the bot failures.

llvm-svn: 366241
  • Loading branch information
preames committed Jul 16, 2019
1 parent 8f8d07e commit 6e1c3bb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,12 @@ bool IndVarSimplify::run(Loop *L) {
if (isa<SCEVCouldNotCompute>(ExitCount))
continue;

assert(!ExitCount->isZero() && "Should have been folded above");
// This was handled above, but as we form SCEVs, we can sometimes refine
// existing ones; this allows exit counts to be folded to zero which
// weren't when optimizeLoopExits saw them. Arguably, we should iterate
// until stable to handle cases like this better.
if (ExitCount->isZero())
continue;

PHINode *IndVar = FindLoopCounter(L, ExitingBB, ExitCount, SE, DT);
if (!IndVar)
Expand Down

0 comments on commit 6e1c3bb

Please sign in to comment.