diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-10-24 06:14:27 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-10-24 06:14:27 +0000 |
commit | 730d5dade654cddf784f9a1bfb120d2f010ae716 (patch) | |
tree | f15fd3061c812a0b8f8ab91a77b640ee441f1221 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | 1359e00f9c4513d62eec39359fed0f40063ab6fd (diff) | |
download | bcm5719-llvm-730d5dade654cddf784f9a1bfb120d2f010ae716.tar.gz bcm5719-llvm-730d5dade654cddf784f9a1bfb120d2f010ae716.zip |
Don't try to create a mask when we don't need one. Fixes a crash.
llvm-svn: 58075
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index d3d0eb61ec1..9f94ee38337 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/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); } |