aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2006-09-20 15:37:57 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2006-09-20 15:37:57 +0000
commit4563326472b000ee501a99f19b912bf9ca134b1f (patch)
treef1c626a53a1918fead820bfae1adcd3110b45ca4 /lib/Transforms
parent6b634037b3bc4d0cf48b2e4760b82c08f2898aa6 (diff)
simplify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 8f6d5348e6..79c204f93e 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1603,18 +1603,14 @@ FoundSExt:
CI = dyn_cast<CastInst>(RHS);
Other = LHS;
}
- if (CI) {
- const Type *UIntPtrTy = TD->getIntPtrType();
- const Type *SIntPtrTy = UIntPtrTy->getSignedVersion();
- if((CI->getType() == UIntPtrTy || CI->getType() == SIntPtrTy)
- && isa<PointerType>(CI->getOperand(0)->getType())) {
- Instruction* I2 = new CastInst(CI->getOperand(0),
- PointerType::get(Type::SByteTy), "ctg", &I);
- WorkList.push_back(I2);
- I2 = new GetElementPtrInst(I2, Other, "ctg", &I);
- WorkList.push_back(I2);
- return new CastInst(I2, CI->getType());
- }
+ if (CI && CI->getType()->isSized() &&
+ (CI->getType()->getPrimitiveSize() ==
+ TD->getIntPtrType()->getPrimitiveSize())
+ && isa<PointerType>(CI->getOperand(0)->getType())) {
+ Value* I2 = InsertCastBefore(CI->getOperand(0),
+ PointerType::get(Type::SByteTy), I);
+ I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
+ return new CastInst(I2, CI->getType());
}
}