diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-12-01 10:58:34 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-12-01 10:58:34 +0000 |
commit | 0c5d6ccbfc089b3335a78d910febff44c3dd622c (patch) | |
tree | 3e286d283381129ed31af749e6144b4d36b8ca92 /llvm/lib/Transforms | |
parent | 958b94d6791a345e2221ee4291cb209a7ec579ba (diff) | |
download | bcm5719-llvm-0c5d6ccbfc089b3335a78d910febff44c3dd622c.tar.gz bcm5719-llvm-0c5d6ccbfc089b3335a78d910febff44c3dd622c.zip |
[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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index f0b09e1f0bd..a023b6da232 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2104,11 +2104,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { } // 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)); |