]> granicus.if.org Git - llvm/commitdiff
Fix a bug in getSCEVAtScope w.r.t. non-canonical loops
authorPhilip Reames <listmail@philipreames.com>
Tue, 11 Jun 2019 23:21:24 +0000 (23:21 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 11 Jun 2019 23:21:24 +0000 (23:21 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363112 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index a7b7fa2623832a4e284415cf5d08cd23a2b16fde..dc2d32856cc4dd7cecde2793c6c0ba6ee70345bb 100644 (file)
@@ -8126,9 +8126,9 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
                     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