From fb384d61c78b60787ed65475d8403aee65023962 Mon Sep 17 00:00:00 2001 From: Micah Villmow Date: Thu, 11 Oct 2012 21:27:41 +0000 Subject: Revert 165732 for further review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165747 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ConstantFolding.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/Analysis/ConstantFolding.cpp') diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 146897ad67..b7bf044a36 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -916,11 +916,10 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy, if (TD && CE->getOpcode() == Instruction::IntToPtr) { Constant *Input = CE->getOperand(0); unsigned InWidth = Input->getType()->getScalarSizeInBits(); - unsigned AS = cast(CE->getType())->getAddressSpace(); - if (TD->getPointerSizeInBits(AS) < InWidth) { + if (TD->getPointerSizeInBits() < InWidth) { Constant *Mask = ConstantInt::get(CE->getContext(), APInt::getLowBitsSet(InWidth, - TD->getPointerSizeInBits(AS))); + TD->getPointerSizeInBits())); Input = ConstantExpr::getAnd(Input, Mask); } // Do a zext or trunc to get to the dest size. @@ -933,10 +932,9 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy, // the int size is >= the ptr size. This requires knowing the width of a // pointer, so it can't be done in ConstantExpr::getCast. if (ConstantExpr *CE = dyn_cast(Ops[0])) - if (TD && CE->getOpcode() == Instruction::PtrToInt && - TD->getPointerSizeInBits( - cast(CE->getOperand(0)->getType())->getAddressSpace()) - <= CE->getType()->getScalarSizeInBits()) + if (TD && + TD->getPointerSizeInBits() <= CE->getType()->getScalarSizeInBits() && + CE->getOpcode() == Instruction::PtrToInt) return FoldBitCast(CE->getOperand(0), DestTy, *TD); return ConstantExpr::getCast(Opcode, Ops[0], DestTy); -- cgit v1.2.3