diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-11-22 20:31:27 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-11-22 20:31:27 +0000 |
commit | 93f8455d73858c418ee7371b8e89094716df8fc7 (patch) | |
tree | e002622a9e480dd345ee8135c7630ccbeef8f159 /lib/Transforms | |
parent | 28ef0a5719c41ed9654156aa9db7a656d020d7b5 (diff) | |
download | external_llvm-93f8455d73858c418ee7371b8e89094716df8fc7.zip external_llvm-93f8455d73858c418ee7371b8e89094716df8fc7.tar.gz external_llvm-93f8455d73858c418ee7371b8e89094716df8fc7.tar.bz2 |
InstCombine: Implement X - A*-B -> X + A*B.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 9b72eb9..c04a6b2 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -675,6 +675,15 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { C2); return BinaryOperator::CreateMul(Op0, CP1); } + + // X - A*-B -> X + A*B + // X - -A*B -> X + A*B + Value *A, *B; + if (match(Op1I, m_Mul(m_Value(A), m_Neg(m_Value(B)))) || + match(Op1I, m_Mul(m_Neg(m_Value(A)), m_Value(B)))) { + Value *NewMul = Builder->CreateMul(A, B); + return BinaryOperator::CreateAdd(Op0, NewMul); + } } } |