Don't attempt aggressive post-inc uses if TargetLowering is not available,
authorDan Gohman <gohman@apple.com>
Sun, 14 Feb 2010 02:45:21 +0000 (02:45 +0000)
committerDan Gohman <gohman@apple.com>
Sun, 14 Feb 2010 02:45:21 +0000 (02:45 +0000)
because profitability can't be sufficiently approximated.

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

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index d3c92e77a09119bf06c674706b10a7d2380a122b..0c65e33c61d267778f546c24d3a5783a28c4f838 100644 (file)
@@ -1503,7 +1503,11 @@ LSRInstance::OptimizeLoopTermCond() {
 
     // Conservatively avoid trying to use the post-inc value in non-latch
     // exits if there may be pre-inc users in intervening blocks.
-    if (LatchBlock != ExitingBlock)
+    if (LatchBlock != ExitingBlock) {
+      // Without target lowering, we won't be able to query about valid reuse.
+      if (!TLI)
+        continue;
+
       for (IVUsers::const_iterator UI = IU.begin(), E = IU.end(); UI != E; ++UI)
         // Test if the use is reachable from the exiting block. This dominator
         // query is a conservative approximation of reachability.
@@ -1535,13 +1539,14 @@ LSRInstance::OptimizeLoopTermCond() {
             const Type *AccessTy = getAccessType(UI->getUser());
             TargetLowering::AddrMode AM;
             AM.Scale = D->getValue()->getSExtValue();
-            if (TLI && TLI->isLegalAddressingMode(AM, AccessTy))
+            if (TLI->isLegalAddressingMode(AM, AccessTy))
               goto decline_post_inc;
             AM.Scale = -AM.Scale;
-            if (TLI && TLI->isLegalAddressingMode(AM, AccessTy))
+            if (TLI->isLegalAddressingMode(AM, AccessTy))
               goto decline_post_inc;
           }
         }
+    }
 
     DEBUG(dbgs() << "  Change loop exiting icmp to use postinc iv: "
                  << *Cond << '\n');