Implement support for simplifying vector comparisons by 0.0 and 1.0 like we
do for scalars.  Patch contributed by Nicolas Capens

This also generalizes the previous xforms to work on long double, now that 
isExactlyValue works for long double.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54653 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index eebb7cf..bdea6e4 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2480,10 +2480,17 @@
 
       // "In IEEE floating point, x*1 is not equivalent to x for nans.  However,
       // ANSI says we can drop signals, so we can do this anyway." (from GCC)
-      // We need a better interface for long double here.
-      if (Op1->getType() == Type::FloatTy || Op1->getType() == Type::DoubleTy)
-        if (Op1F->isExactlyValue(1.0))
-          return ReplaceInstUsesWith(I, Op0);  // Eliminate 'mul double %X, 1.0'
+      if (Op1F->isExactlyValue(1.0))
+        return ReplaceInstUsesWith(I, Op0);  // Eliminate 'mul double %X, 1.0'
+    } else if (isa<VectorType>(Op1->getType())) {
+      if (isa<ConstantAggregateZero>(Op1))
+        return ReplaceInstUsesWith(I, Op1);
+      
+      // As above, vector X*splat(1.0) -> X in all defined cases.
+      if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1))
+        if (ConstantFP *F = dyn_cast_or_null<ConstantFP>(Op1V->getSplatValue()))
+          if (F->isExactlyValue(1.0))
+            return ReplaceInstUsesWith(I, Op0);
     }
     
     if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0))
@@ -11636,3 +11643,4 @@
   return new InstCombiner();
 }
 
+