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 | 04aa2c3520c049333ca216fb794d700310c4a33d (patch) | |
tree | b658f4581ef7cb57b7b65d7bba010256b8c1887d /lib/Analysis/ConstantFolding.cpp | |
parent | 2efe3fd79a751eabe1664109a004af45dca99274 (diff) |
Don't try to create a mask when we don't need one. Fixes a crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index d3d0eb61ec..9f94ee3833 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); } |