Change inferred getCast into specific getCast. Passes all tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32469 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 6d449d0..703a1c4 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -1566,7 +1566,9 @@
         // comparison.
         ConstantInt *CompVal = RHSC->getValue();
         const Type *RealTy = ExitCond->getOperand(0)->getType();
-        CompVal = dyn_cast<ConstantInt>(ConstantExpr::getCast(CompVal, RealTy));
+        CompVal = dyn_cast<ConstantInt>(
+          ConstantExpr::getIntegerCast(CompVal, RealTy, 
+                                       CompVal->getType()->isSigned()));
         if (CompVal) {
           // Form the constant range.
           ConstantRange CompRange(Cond, CompVal);
@@ -1575,8 +1577,12 @@
           // range.
           if (CompRange.getLower()->getType()->isSigned()) {
             const Type *NewTy = RHSC->getValue()->getType();
-            Constant *NewL = ConstantExpr::getCast(CompRange.getLower(), NewTy);
-            Constant *NewU = ConstantExpr::getCast(CompRange.getUpper(), NewTy);
+            Constant *NewL = 
+              ConstantExpr::getIntegerCast(CompRange.getLower(), NewTy, 
+                 CompRange.getLower()->getType()->isSigned());
+            Constant *NewU = 
+              ConstantExpr::getIntegerCast(CompRange.getUpper(), NewTy,
+                 CompRange.getUpper()->getType()->isSigned());
             CompRange = ConstantRange(NewL, NewU);
           }