[llvm] r363112 - Fix a bug in getSCEVAtScope w.r.t. non-canonical loops

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 16:21:24 PDT 2019


Author: reames
Date: Tue Jun 11 16:21:24 2019
New Revision: 363112

URL: http://llvm.org/viewvc/llvm-project?rev=363112&view=rev
Log:
Fix a bug in getSCEVAtScope w.r.t. non-canonical loops

The issue is that if we have a loop with multiple predecessors outside the loop, the code was expecting to merge them and only return if equal, but instead returned the first one seen.

I have no idea if this actually tripped anywhere.  I noticed it by accident when reading the code and have no idea how to go about constructing a test case.


Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=363112&r1=363111&r2=363112&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jun 11 16:21:24 2019
@@ -8126,9 +8126,9 @@ const SCEV *ScalarEvolution::computeSCEV
                     break;
                   }
                 }
-                if (!MultipleInitValues && InitValue)
-                  return getSCEV(InitValue);
               }
+              if (!MultipleInitValues && InitValue)
+                return getSCEV(InitValue);
             }
             // Okay, we know how many times the containing loop executes.  If
             // this is a constant evolving PHI node, get the final value at




More information about the llvm-commits mailing list