summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-20 23:35:48 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-20 23:35:48 +0000
commit9a4bed06dd0a9e95a893d27b01fe8d9d3b31cbb1 (patch)
treeb42dfe128f330e9944a78f370f3bffbb53b331e4 /llvm
parent2239163496f18d07301cfa738c2f76459ae695de (diff)
downloadbcm5719-llvm-9a4bed06dd0a9e95a893d27b01fe8d9d3b31cbb1.tar.gz
bcm5719-llvm-9a4bed06dd0a9e95a893d27b01fe8d9d3b31cbb1.zip
Revise the store V, (cast P) -> store (cast V) -> P transform.
We only want to do this if the src and destination types have the same bit width. This patch uses TargetData::getTypeSizeInBits() instead of making a special case for integer types and avoiding the transform if they don't match. llvm-svn: 33414
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 04b06d28aa7..a87a8ad575c 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -8192,10 +8192,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
SrcPTy = SrcTy->getElementType();
}
- if (((SrcPTy->isInteger() && SrcPTy != Type::Int1Ty) ||
- isa<PointerType>(SrcPTy)) &&
- IC.getTargetData().getTypeSize(SrcPTy) ==
- IC.getTargetData().getTypeSize(DestPTy)) {
+ if ((SrcPTy->isInteger() || isa<PointerType>(SrcPTy)) &&
+ IC.getTargetData().getTypeSizeInBits(SrcPTy) ==
+ IC.getTargetData().getTypeSizeInBits(DestPTy)) {
// Okay, we are casting from one integer or pointer type to another of
// the same size. Instead of casting the pointer before
@@ -8208,13 +8207,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
if (isa<PointerType>(CastDstTy)) {
if (CastSrcTy->isInteger())
opcode = Instruction::IntToPtr;
- } else if (const IntegerType* DITy = dyn_cast<IntegerType>(CastDstTy)) {
+ } else if (isa<IntegerType>(CastDstTy)) {
if (isa<PointerType>(SIOp0->getType()))
opcode = Instruction::PtrToInt;
- else if (const IntegerType* SITy = dyn_cast<IntegerType>(CastSrcTy))
- 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