When testing whether one loop contains another, test this directly
authorDan Gohman <gohman@apple.com>
Fri, 13 Aug 2010 20:23:25 +0000 (20:23 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 13 Aug 2010 20:23:25 +0000 (20:23 +0000)
rather than testing whether the loop contains the other's header.

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

lib/Analysis/ScalarEvolution.cpp

index 6bb121f82ab078c647ad61b400eb3b438c55c44b..2cf8fff32b08243d2384d8c98dff20542c80fdd3 100644 (file)
@@ -2047,9 +2047,9 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
   // Canonicalize nested AddRecs in by nesting them in order of loop depth.
   if (const SCEVAddRecExpr *NestedAR = dyn_cast<SCEVAddRecExpr>(Operands[0])) {
     const Loop *NestedLoop = NestedAR->getLoop();
-    if (L->contains(NestedLoop->getHeader()) ?
+    if (L->contains(NestedLoop) ?
         (L->getLoopDepth() < NestedLoop->getLoopDepth()) :
-        (!NestedLoop->contains(L->getHeader()) &&
+        (!NestedLoop->contains(L) &&
          DT->dominates(L->getHeader(), NestedLoop->getHeader()))) {
       SmallVector<const SCEV *, 4> NestedOperands(NestedAR->op_begin(),
                                                   NestedAR->op_end());