Instrcombine should not change load(cast p) to cast(load p) if the cast

changes the address space of the pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64035 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mon P Wang
2009-02-07 22:19:29 +00:00
parent 6f38cb61a9
commit 6753f959d2
2 changed files with 26 additions and 1 deletions
@@ -11007,8 +11007,14 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI,
}
}
const Type *DestPTy = cast<PointerType>(CI->getType())->getElementType();
const PointerType *DestTy = cast<PointerType>(CI->getType());
const Type *DestPTy = DestTy->getElementType();
if (const PointerType *SrcTy = dyn_cast<PointerType>(CastOp->getType())) {
// If the address spaces don't match, don't eliminate the cast.
if (DestTy->getAddressSpace() != SrcTy->getAddressSpace())
return 0;
const Type *SrcPTy = SrcTy->getElementType();
if (DestPTy->isInteger() || isa<PointerType>(DestPTy) ||