summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
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
commite928a15c9edcd46609eef81fcc92b2ec4314f93e (patch)
tree6cd35dee07ae2a605136e35b9514a7e550259341 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parenta94d394ad2ae63071ae1fd203ea28f50066a5879 (diff)
downloadbcm5719-llvm-e928a15c9edcd46609eef81fcc92b2ec4314f93e.tar.gz
bcm5719-llvm-e928a15c9edcd46609eef81fcc92b2ec4314f93e.zip
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. llvm-svn: 33371
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index fd6d23e28f1..414ae794b18 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud