[InstCombine] Support ssub.sat canonicalization for non-splats

Extend ssub.sat(X, C) -> sadd.sat(X, -C) canonicalization to also
support non-splat vector constants. This is done by generalizing
the implementation of the isNotMinSignedValue() helper to return
true for constants that are non-splat, but don't contain any
signed min elements.

Differential Revision: https://reviews.llvm.org/D55011

llvm-svn: 348072
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index f0b09e1..a023b6d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2104,11 +2104,10 @@
     }
 
     // ssub.sat(X, C) -> sadd.sat(X, -C) if C != MIN
-    // TODO: Support non-splat C.
-    const APInt *C;
-    if (IID == Intrinsic::ssub_sat && match(Arg1, m_APInt(C)) &&
-        !C->isMinSignedValue()) {
-      Value *NegVal = ConstantInt::get(II->getType(), -*C);
+    Constant *C;
+    if (IID == Intrinsic::ssub_sat && match(Arg1, m_Constant(C)) &&
+        C->isNotMinSignedValue()) {
+      Value *NegVal = ConstantExpr::getNeg(C);
       return replaceInstUsesWith(
           *II, Builder.CreateBinaryIntrinsic(
               Intrinsic::sadd_sat, Arg0, NegVal));