[llvm-commits] [SignlessTypes] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp ConstantFolding.cpp ConstantRange.cpp ScalarEvolution.cpp

Reid Spencer reid at x10sys.com
Wed Oct 18 20:58:57 PDT 2006



Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.86 -> 1.86.2.1
ConstantFolding.cpp updated: 1.4 -> 1.4.4.1
ConstantRange.cpp updated: 1.15 -> 1.15.2.1
ScalarEvolution.cpp updated: 1.53 -> 1.53.2.1
---
Log message:

For PR950: http://llvm.org/PR950 :
This commit (on SignlessTypes branch) provides the first Iteration for 
moving LLVM away from Signed types. This patch removes the ConstantSInt
and ConstantUInt classes from Type.h and makes all necessary changes in
LLVM to compensate.


---
Diffs of the changes:  (+23 -23)

 BasicAliasAnalysis.cpp |   11 +++++------
 ConstantFolding.cpp    |   11 ++++++-----
 ConstantRange.cpp      |    2 +-
 ScalarEvolution.cpp    |   22 +++++++++++-----------
 4 files changed, 23 insertions(+), 23 deletions(-)


Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.86 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.86.2.1
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.86	Wed Oct  4 16:52:35 2006
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp	Wed Oct 18 22:57:55 2006
@@ -468,11 +468,10 @@
 /// CheckGEPInstructions - Check two GEP instructions with known must-aliasing
 /// base pointers.  This checks to see if the index expressions preclude the
 /// pointers from aliasing...
-AliasAnalysis::AliasResult BasicAliasAnalysis::
-CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops,
-                     unsigned G1S,
-                     const Type *BasePtr2Ty, std::vector<Value*> &GEP2Ops,
-                     unsigned G2S) {
+AliasAnalysis::AliasResult 
+BasicAliasAnalysis::CheckGEPInstructions(
+  const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, unsigned G1S,
+  const Type *BasePtr2Ty, std::vector<Value*> &GEP2Ops, unsigned G2S) {
   // We currently can't handle the case when the base pointers have different
   // primitive types.  Since this is uncommon anyway, we are happy being
   // extremely conservative.
@@ -685,7 +684,7 @@
           // value possible.
           //
           if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
-            GEP1Ops[i] = ConstantSInt::get(Type::LongTy,AT->getNumElements()-1);
+            GEP1Ops[i] = ConstantInt::get(Type::LongTy, AT->getNumElements()-1);
         }
       }
 


Index: llvm/lib/Analysis/ConstantFolding.cpp
diff -u llvm/lib/Analysis/ConstantFolding.cpp:1.4 llvm/lib/Analysis/ConstantFolding.cpp:1.4.4.1
--- llvm/lib/Analysis/ConstantFolding.cpp:1.4	Sat Jun 17 13:17:52 2006
+++ llvm/lib/Analysis/ConstantFolding.cpp	Wed Oct 18 22:57:55 2006
@@ -163,14 +163,15 @@
         default:
           break;
       }
-    } else if (ConstantUInt *Op = dyn_cast<ConstantUInt>(Operands[0])) {
-      uint64_t V = Op->getValue();
+    } else if (ConstantInt *Op = dyn_cast<ConstantInt>(Operands[0])) {
+      assert(Op->getType()->isUnsigned() && "bswap args must be unsigned");
+      uint64_t V = Op->getZExtValue();
       if (Name == "llvm.bswap.i16")
-        return ConstantUInt::get(Ty, ByteSwap_16(V));
+        return ConstantInt::get(Ty, ByteSwap_16(V));
       else if (Name == "llvm.bswap.i32")
-        return ConstantUInt::get(Ty, ByteSwap_32(V));
+        return ConstantInt::get(Ty, ByteSwap_32(V));
       else if (Name == "llvm.bswap.i64")
-        return ConstantUInt::get(Ty, ByteSwap_64(V));
+        return ConstantInt::get(Ty, ByteSwap_64(V));
     }
   } else if (Operands.size() == 2) {
     if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {


Index: llvm/lib/Analysis/ConstantRange.cpp
diff -u llvm/lib/Analysis/ConstantRange.cpp:1.15 llvm/lib/Analysis/ConstantRange.cpp:1.15.2.1
--- llvm/lib/Analysis/ConstantRange.cpp:1.15	Thu Sep 28 18:14:29 2006
+++ llvm/lib/Analysis/ConstantRange.cpp	Wed Oct 18 22:57:55 2006
@@ -288,7 +288,7 @@
     // Change a source full set into [0, 1 << 8*numbytes)
     unsigned SrcTySize = getLower()->getType()->getPrimitiveSize();
     return ConstantRange(Constant::getNullValue(Ty),
-                         ConstantUInt::get(Ty, 1ULL << SrcTySize*8));
+                         ConstantInt::get(Ty, 1ULL << SrcTySize*8));
   }
 
   Constant *Lower = getLower();


Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.53 llvm/lib/Analysis/ScalarEvolution.cpp:1.53.2.1
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.53	Wed Oct  4 16:49:37 2006
+++ llvm/lib/Analysis/ScalarEvolution.cpp	Wed Oct 18 22:57:55 2006
@@ -177,7 +177,7 @@
   // Make sure that SCEVConstant instances are all unsigned.
   if (V->getType()->isSigned()) {
     const Type *NewTy = V->getType()->getUnsignedVersion();
-    V = cast<ConstantUInt>(ConstantExpr::getCast(V, NewTy));
+    V = cast<ConstantInt>(ConstantExpr::getCast(V, NewTy));
   }
 
   SCEVConstant *&R = (*SCEVConstants)[V];
@@ -463,9 +463,9 @@
   else if (Ty->isFloatingPoint())
     C = ConstantFP::get(Ty, Val);
   else if (Ty->isSigned())
-    C = ConstantSInt::get(Ty, Val);
+    C = ConstantInt::get(Ty, Val);
   else {
-    C = ConstantSInt::get(Ty->getSignedVersion(), Val);
+    C = ConstantInt::get(Ty->getSignedVersion(), Val);
     C = ConstantExpr::getCast(C, Ty);
   }
   return SCEVUnknown::get(C);
@@ -511,7 +511,7 @@
     uint64_t Result = 1;
     for (; NumSteps; --NumSteps)
       Result *= Val-(NumSteps-1);
-    Constant *Res = ConstantUInt::get(Type::ULongTy, Result);
+    Constant *Res = ConstantInt::get(Type::ULongTy, Result);
     return SCEVUnknown::get(ConstantExpr::getCast(Res, V->getType()));
   }
 
@@ -1679,8 +1679,8 @@
 
   unsigned MaxSteps = MaxBruteForceIterations;
   for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) {
-    ConstantUInt *ItCst =
-      ConstantUInt::get(IdxExpr->getType()->getUnsignedVersion(), IterationNum);
+    ConstantInt *ItCst =
+      ConstantInt::get(IdxExpr->getType()->getUnsignedVersion(), IterationNum);
     ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst);
 
     // Form the GEP offset.
@@ -1896,7 +1896,7 @@
     if (CondVal->getValue() == ExitWhen) {
       ConstantEvolutionLoopExitValue[PN] = PHIVal;
       ++NumBruteForceTripCountsComputed;
-      return SCEVConstant::get(ConstantUInt::get(Type::UIntTy, IterationNum));
+      return SCEVConstant::get(ConstantInt::get(Type::UIntTy, IterationNum));
     }
 
     // Compute the value of the PHI node for the next iteration.
@@ -2076,10 +2076,10 @@
   SqrtTerm = ConstantExpr::getSub(ConstantExpr::getMul(B, B), SqrtTerm);
 
   // Compute floor(sqrt(B^2-4ac))
-  ConstantUInt *SqrtVal =
-    cast<ConstantUInt>(ConstantExpr::getCast(SqrtTerm,
+  ConstantInt *SqrtVal =
+    cast<ConstantInt>(ConstantExpr::getCast(SqrtTerm,
                                    SqrtTerm->getType()->getUnsignedVersion()));
-  uint64_t SqrtValV = SqrtVal->getValue();
+  uint64_t SqrtValV = SqrtVal->getZExtValue();
   uint64_t SqrtValV2 = (uint64_t)sqrt((double)SqrtValV);
   // The square root might not be precise for arbitrary 64-bit integer
   // values.  Do some sanity checks to ensure it's correct.
@@ -2089,7 +2089,7 @@
     return std::make_pair(CNC, CNC);
   }
 
-  SqrtVal = ConstantUInt::get(Type::ULongTy, SqrtValV2);
+  SqrtVal = ConstantInt::get(Type::ULongTy, SqrtValV2);
   SqrtTerm = ConstantExpr::getCast(SqrtVal, SqrtTerm->getType());
 
   Constant *NegB = ConstantExpr::getNeg(B);






More information about the llvm-commits mailing list