[llvm] r366241 - [IndVars] Speculative fix for an assertion failure seen in bots

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 11:23:50 PDT 2019


Author: reames
Date: Tue Jul 16 11:23:49 2019
New Revision: 366241

URL: http://llvm.org/viewvc/llvm-project?rev=366241&view=rev
Log:
[IndVars] Speculative fix for an assertion failure seen in bots

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.


Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=366241&r1=366240&r2=366241&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Jul 16 11:23:49 2019
@@ -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)




More information about the llvm-commits mailing list