For this transform: store V, (cast P) -> store (cast V), P

don't allow the transform if V and the pointer's element type are different
width integer types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33371 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-01-19 21:20:31 +00:00
parent c10305743c
commit 55af2b59bb

View File

@ -8162,7 +8162,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
return 0;
}
/// InstCombineStoreToCast - Fold 'store V, (cast P)' -> store (cast V), P'
/// InstCombineStoreToCast - Fold store V, (cast P) -> store (cast V), P
/// when possible.
static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
User *CI = cast<User>(SI.getOperand(1));
@ -8206,8 +8206,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
if (isa<PointerType>(SIOp0->getType()))
opcode = Instruction::PtrToInt;
else if (const IntegerType* SITy = dyn_cast<IntegerType>(CastSrcTy))
assert(DITy->getBitWidth() == SITy->getBitWidth() &&
"Illegal store instruction");
if (SITy->getBitWidth() != DITy->getBitWidth())
return 0; // Don't do this transform on unequal bit widths.
// else, BitCast is fine
}
if (Constant *C = dyn_cast<Constant>(SIOp0))
NewCast = ConstantExpr::getCast(opcode, C, CastDstTy);