Simplify test, as suggested by Chris.
authorAnders Carlsson <andersca@mac.com>
Sun, 6 Feb 2011 20:22:49 +0000 (20:22 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 6 Feb 2011 20:22:49 +0000 (20:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124990 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp

index 6c99ad32bbe75b44daf15847aca4c3bf367846e8..95e8bde2a83bc1646391eabe3694cddd04bdc6f7 100644 (file)
@@ -341,14 +341,10 @@ static bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset,
   }
   
   if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
-    if (CE->getOpcode() == Instruction::IntToPtr) {
-      uint64_t PtrSize = TD.getTypeAllocSize(C->getType());
-      uint64_t IntSize = TD.getTypeAllocSize(C->getOperand(0)->getType());
-
-      if (PtrSize == IntSize)
+    if (CE->getOpcode() == Instruction::IntToPtr &&
+        CE->getOperand(0)->getType() == TD.getIntPtrType(CE->getContext())) 
         return ReadDataFromGlobal(CE->getOperand(0), ByteOffset, CurPtr, 
                                   BytesLeft, TD);
-    }
   }
 
   // Otherwise, unknown initializer type.