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
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index ce471b3..d12ad81 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -9934,9 +9934,9 @@
         // 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 @@
         // 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 @@
       // 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 @@
       // 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 @@
       
       // 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;