Use type helper functions
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 27 Sep 2013 22:18:51 +0000 (22:18 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 27 Sep 2013 22:18:51 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191574 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicAliasAnalysis.cpp
lib/Transforms/InstCombine/InstCombineCalls.cpp
lib/Transforms/InstCombine/InstCombineCompares.cpp

index 9de5b22e1d18741750de40fabd7fab4f3f40cc78..bf929690ae779fbb9bf8f5fd108b6b7d93820099 100644 (file)
@@ -313,8 +313,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
     }
 
     // Don't attempt to analyze GEPs over unsized objects.
-    if (!cast<PointerType>(GEPOp->getOperand(0)->getType())
-        ->getElementType()->isSized())
+    if (!GEPOp->getOperand(0)->getType()->getPointerElementType()->isSized())
       return V;
 
     // If we are lacking DataLayout information, we can't compute the offets of
@@ -354,7 +353,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
 
       // If the integer type is smaller than the pointer size, it is implicitly
       // sign extended to pointer size.
-      unsigned Width = cast<IntegerType>(Index->getType())->getBitWidth();
+      unsigned Width = Index->getType()->getIntegerBitWidth();
       if (TD->getPointerSizeInBits() > Width)
         Extension = EK_SignExt;
 
index beb63e8d53daf20600b3ab614d5e638ad9ca4c53..0cd7b149d42a975471019e8bc0e2d40ebf780aeb 100644 (file)
@@ -1057,7 +1057,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
       if (ParamPTy == 0 || !ParamPTy->getElementType()->isSized() || TD == 0)
         return false;
 
-      Type *CurElTy = cast<PointerType>(ActTy)->getElementType();
+      Type *CurElTy = ActTy->getPointerElementType();
       if (TD->getTypeAllocSize(CurElTy) !=
           TD->getTypeAllocSize(ParamPTy->getElementType()))
         return false;
index 2c292ce29d0a22e99bb2044f59b2914889b52286..402f8c330290dab3f9ef2e19b5d66bdf5af7b708 100644 (file)
@@ -1782,8 +1782,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
   // Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
   // integer type is the same size as the pointer type.
   if (TD && LHSCI->getOpcode() == Instruction::PtrToInt &&
-      TD->getPointerSizeInBits() ==
-         cast<IntegerType>(DestTy)->getBitWidth()) {
+      TD->getPointerSizeInBits() == DestTy->getIntegerBitWidth()) {
     Value *RHSOp = 0;
     if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1))) {
       RHSOp = ConstantExpr::getIntToPtr(RHSC, SrcTy);