Don't attempt aggressive post-inc uses if TargetLowering is not available,
[oota-llvm.git] / lib / Transforms / Scalar / LoopStrengthReduce.cpp
index 8dba947d04a72155517186365f01d15ac3ebd9cb..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.
@@ -1542,6 +1546,7 @@ LSRInstance::OptimizeLoopTermCond() {
               goto decline_post_inc;
           }
         }
+    }
 
     DEBUG(dbgs() << "  Change loop exiting icmp to use postinc iv: "
                  << *Cond << '\n');