aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-19 21:20:31 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-19 21:20:31 +0000
commit55af2b59bba38230c78f985dd6243d8f473c6ac8 (patch)
treec3c33ad1f44c3a831f0c2f0121bf7ec7717c9ced
parentc10305743c313558405079452138f03124e87581 (diff)
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
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index fd6d23e28f..414ae794b1 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -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);