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 | d12e8020ec232eeeb6c1487ea89cc7b72e0cc15b (patch) | |
tree | 37f19584124ac8283752ac2372b7ec2a9deb8910 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | c1e7621e012ddb936ee96ee3955bfb9311bff7cc (diff) | |
download | bcm5719-llvm-d12e8020ec232eeeb6c1487ea89cc7b72e0cc15b.tar.gz bcm5719-llvm-d12e8020ec232eeeb6c1487ea89cc7b72e0cc15b.zip |
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.
llvm-svn: 190899
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 9b7999c4e3f..22f36e56bcf 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/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. |