diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-09-17 23:23:16 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-09-17 23:23:16 +0000 |
commit | 2334b0e8023bc382585a08386510cf29b3d541a6 (patch) | |
tree | 179bdc4106993e50616a416efd63688d63d250c8 /lib | |
parent | 28860823ad34d41d4f58561dc14a982fb0843fdd (diff) | |
download | llvm-2334b0e8023bc382585a08386510cf29b3d541a6.tar.gz llvm-2334b0e8023bc382585a08386510cf29b3d541a6.tar.bz2 llvm-2334b0e8023bc382585a08386510cf29b3d541a6.tar.xz |
Fix a constant folding address space place I missed.
If address space 0 was smaller than the address space
in a constant inttoptr/ptrtoint pair, the wrong mask size
would be used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 9b7999c4e3..22f36e56bc 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -974,10 +974,11 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy, if (TD && CE->getOpcode() == Instruction::IntToPtr) { Constant *Input = CE->getOperand(0); unsigned InWidth = Input->getType()->getScalarSizeInBits(); - if (TD->getPointerTypeSizeInBits(CE->getType()) < InWidth) { + unsigned PtrWidth = TD->getPointerTypeSizeInBits(CE->getType()); + if (PtrWidth < InWidth) { Constant *Mask = - ConstantInt::get(CE->getContext(), APInt::getLowBitsSet(InWidth, - TD->getPointerSizeInBits())); + ConstantInt::get(CE->getContext(), + APInt::getLowBitsSet(InWidth, PtrWidth)); Input = ConstantExpr::getAnd(Input, Mask); } // Do a zext or trunc to get to the dest size. |