make sure that we don't use a common symbol if a section was specified
[oota-llvm.git] / lib / Analysis / ScalarEvolutionExpander.cpp
index fd33e2fae2b1c91bdcec9aafefe208c9631b2f3d..9432cc278b97b255e933bd36891c785ebdc57c3e 100644 (file)
@@ -13,8 +13,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/ScalarEvolutionExpander.h"
+#include "llvm/Analysis/LoopInfo.h"
 using namespace llvm;
 
 /// InsertCastOfTo - Insert a cast of V to the specified type, doing what
@@ -30,8 +30,7 @@ Value *SCEVExpander::InsertCastOfTo(Value *V, const Type *Ty) {
          UI != E; ++UI) {
       if ((*UI)->getType() == Ty)
         if (CastInst *CI = dyn_cast<CastInst>(cast<Instruction>(*UI))) {
-          // If the cast isn't in the first instruction of the function,
-          // move it.
+          // If the cast isn't the first instruction of the function, move it.
           if (BasicBlock::iterator(CI) != 
               A->getParent()->getEntryBlock().begin()) {
             CI->moveBefore(A->getParent()->getEntryBlock().begin());
@@ -39,8 +38,8 @@ Value *SCEVExpander::InsertCastOfTo(Value *V, const Type *Ty) {
           return CI;
         }
     }
-    return new CastInst(V, Ty, V->getName(),
-                        A->getParent()->getEntryBlock().begin());
+    return CastInst::createInferredCast(
+        V, Ty, V->getName(), A->getParent()->getEntryBlock().begin());
   }
     
   Instruction *I = cast<Instruction>(V);
@@ -65,7 +64,7 @@ Value *SCEVExpander::InsertCastOfTo(Value *V, const Type *Ty) {
   if (InvokeInst *II = dyn_cast<InvokeInst>(I))
     IP = II->getNormalDest()->begin();
   while (isa<PHINode>(IP)) ++IP;
-  return new CastInst(V, Ty, V->getName(), IP);
+  return CastInst::createInferredCast(V, Ty, V->getName(), IP);
 }
 
 Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
@@ -144,7 +143,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
     
     // IF the step is by one, just return the inserted IV.
     if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(F))
-      if (CI->getRawValue() == 1)
+      if (CI->getZExtValue() == 1)
         return I;
     
     // If the insert point is directly inside of the loop, emit the multiply at
@@ -175,7 +174,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
   SCEVHandle IH = SCEVUnknown::get(I);   // Get I as a "symbolic" SCEV.
 
   SCEVHandle V = S->evaluateAtIteration(IH);
-  //std::cerr << "Evaluated: " << *this << "\n     to: " << *V << "\n";
+  //cerr << "Evaluated: " << *this << "\n     to: " << *V << "\n";
 
   return expandInTy(V, Ty);
 }