diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-15 05:50:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-15 05:50:18 +0000 |
commit | 67920320b26cbc8c1203ee94654ac1ce1fd2af13 (patch) | |
tree | 49c543791ecd547e70e98ff0275bfcb88d7ce6c5 /lib/Transforms | |
parent | 27a98482bd70dd12eecd02ad600f78a2fc6c16a2 (diff) | |
download | external_llvm-67920320b26cbc8c1203ee94654ac1ce1fd2af13.zip external_llvm-67920320b26cbc8c1203ee94654ac1ce1fd2af13.tar.gz external_llvm-67920320b26cbc8c1203ee94654ac1ce1fd2af13.tar.bz2 |
one more instcombine variant that is needed to work with future changes,
no functionality change currently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123517 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 c4132b2..e5d9a8b 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -672,6 +672,15 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { Value *NewMul = Builder->CreateMul(A, B); return BinaryOperator::CreateAdd(Op0, NewMul); } + + // X - A*Cst -> X + A*-Cst + // X - Cst*A -> X + A*-Cst + ConstantInt *BCst; + if (match(Op1I, m_Mul(m_Value(A), m_ConstantInt(BCst))) || + match(Op1I, m_Mul(m_ConstantInt(BCst), m_Value(A)))) { + Value *NewMul = Builder->CreateMul(A, ConstantExpr::getNeg(BCst)); + return BinaryOperator::CreateAdd(Op0, NewMul); + } } } |