aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-29 02:57:29 +0000
committerChris Lattner <sabre@nondot.org>2009-11-29 02:57:29 +0000
commitcd188e9665b3ff50d57a91b267bb6294ed646539 (patch)
tree77d22a5d9b0c5d7ced5d215f668ab7bcd2ca6e14 /lib/Transforms
parentf4538795fe8763821ce1420783046bb7767df098 (diff)
add testcases for the foo_with_overflow op xforms added recently and
fix bugs exposed by the tests. Testcases from Alastair Lynn! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index ce471b398c..d12ad815f5 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -9934,9 +9934,9 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Create a simple add instruction, and insert it into the struct.
Instruction *Add = BinaryOperator::CreateAdd(LHS, RHS, "", &CI);
Worklist.Add(Add);
- Constant *V[2];
- V[0] = UndefValue::get(LHS->getType());
- V[1] = ConstantInt::getTrue(*Context);
+ Constant *V[] = {
+ UndefValue::get(LHS->getType()), ConstantInt::getTrue(*Context)
+ };
Constant *Struct = ConstantStruct::get(*Context, V, 2, false);
return InsertValueInst::Create(Struct, Add, 0);
}
@@ -9946,9 +9946,9 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Create a simple add instruction, and insert it into the struct.
Instruction *Add = BinaryOperator::CreateNUWAdd(LHS, RHS, "", &CI);
Worklist.Add(Add);
- Constant *V[2];
- V[0] = UndefValue::get(LHS->getType());
- V[1] = ConstantInt::getFalse(*Context);
+ Constant *V[] = {
+ UndefValue::get(LHS->getType()), ConstantInt::getFalse(*Context)
+ };
Constant *Struct = ConstantStruct::get(*Context, V, 2, false);
return InsertValueInst::Create(Struct, Add, 0);
}
@@ -9973,7 +9973,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// X + 0 -> {X, false}
if (RHS->isZero()) {
Constant *V[] = {
- UndefValue::get(II->getType()), ConstantInt::getFalse(*Context)
+ UndefValue::get(II->getOperand(0)->getType()),
+ ConstantInt::getFalse(*Context)
};
Constant *Struct = ConstantStruct::get(*Context, V, 2, false);
return InsertValueInst::Create(Struct, II->getOperand(1), 0);
@@ -9992,7 +9993,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// X - 0 -> {X, false}
if (RHS->isZero()) {
Constant *V[] = {
- UndefValue::get(II->getType()), ConstantInt::getFalse(*Context)
+ UndefValue::get(II->getOperand(1)->getType()),
+ ConstantInt::getFalse(*Context)
};
Constant *Struct = ConstantStruct::get(*Context, V, 2, false);
return InsertValueInst::Create(Struct, II->getOperand(1), 0);
@@ -10021,11 +10023,12 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// X * 1 -> {X, false}
if (RHSI->equalsInt(1)) {
- Constant *V[2];
- V[0] = UndefValue::get(II->getType());
- V[1] = ConstantInt::getFalse(*Context);
+ Constant *V[] = {
+ UndefValue::get(II->getOperand(1)->getType()),
+ ConstantInt::getFalse(*Context)
+ };
Constant *Struct = ConstantStruct::get(*Context, V, 2, false);
- return InsertValueInst::Create(Struct, II->getOperand(1), 1);
+ return InsertValueInst::Create(Struct, II->getOperand(1), 0);
}
}
break;