X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FConstantFolding.cpp;h=9f94ee383374abf100ae8bd1e714162771e99aac;hb=24d3b38a0a02a31f524aa73892e1558160ea70bc;hp=d3d0eb61ec15c0146ff6cc544d65fff6ebdcc20a;hpb=81b06be055e74a3c23a1c8f17ead97f9f76335ee;p=oota-llvm.git diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index d3d0eb61ec1..9f94ee38337 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -368,10 +368,12 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, if (TD && CE->getOpcode() == Instruction::IntToPtr) { Constant *Input = CE->getOperand(0); unsigned InWidth = Input->getType()->getPrimitiveSizeInBits(); - Constant *Mask = - ConstantInt::get(APInt::getLowBitsSet(InWidth, - TD->getPointerSizeInBits())); - Input = ConstantExpr::getAnd(Input, Mask); + if (TD->getPointerSizeInBits() < InWidth) { + Constant *Mask = + ConstantInt::get(APInt::getLowBitsSet(InWidth, + TD->getPointerSizeInBits())); + Input = ConstantExpr::getAnd(Input, Mask); + } // Do a zext or trunc to get to the dest size. return ConstantExpr::getIntegerCast(Input, DestTy, false); }