From 2361a5c2bfbaef476824e51fa72712e334219c7b Mon Sep 17 00:00:00 2001
From: ed <ed@FreeBSD.org>
Date: Sat, 6 Jun 2009 08:20:29 +0000
Subject: Import LLVM, at r72995.

We should now have support for #pragma weak.
---
 lib/Transforms/Scalar/LoopStrengthReduce.cpp | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

(limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')

diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 92270b5..944f409 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2268,7 +2268,8 @@ void LoopStrengthReduce::OptimizeShadowIV(Loop *L) {
       /* create new increment. '++d' in above example. */
       ConstantFP *CFP = ConstantFP::get(DestTy, C->getZExtValue());
       BinaryOperator *NewIncr = 
-        BinaryOperator::Create(Incr->getOpcode(),
+        BinaryOperator::Create(Incr->getOpcode() == Instruction::Add ?
+                                 Instruction::FAdd : Instruction::FSub,
                                NewPH, CFP, "IV.S.next.", Incr);
 
       NewPH->addIncoming(NewInit, PH->getIncomingBlock(Entry));
@@ -2424,24 +2425,14 @@ void LoopStrengthReduce::OptimizeLoopCountIV(Loop *L) {
 
   // Get the terminating condition for the loop if possible (this isn't
   // necessarily in the latch, or a block that's a predecessor of the header).
-  SmallVector<BasicBlock*, 8> ExitBlocks;
-  L->getExitBlocks(ExitBlocks);
-  if (ExitBlocks.size() != 1) return;
+  if (!L->getExitBlock())
+    return; // More than one loop exit blocks.
 
   // Okay, there is one exit block.  Try to find the condition that causes the
   // loop to be exited.
-  BasicBlock *ExitBlock = ExitBlocks[0];
-
-  BasicBlock *ExitingBlock = 0;
-  for (pred_iterator PI = pred_begin(ExitBlock), E = pred_end(ExitBlock);
-       PI != E; ++PI)
-    if (L->contains(*PI)) {
-      if (ExitingBlock == 0)
-        ExitingBlock = *PI;
-      else
-        return; // More than one block exiting!
-    }
-  assert(ExitingBlock && "No exits from loop, something is broken!");
+  BasicBlock *ExitingBlock = L->getExitingBlock();
+  if (!ExitingBlock)
+    return; // More than one block exiting!
 
   // Okay, we've computed the exiting block.  See what condition causes us to
   // exit.
-- 
cgit v1.1