diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-02-11 21:46:48 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-02-11 21:46:48 +0000 |
commit | 1800d823de1ec72d827f12ca340d5ca2d2a81510 (patch) | |
tree | 880138d29849fb4f4f46845d2d58f56fb3738c62 /llvm/lib/Transforms | |
parent | 7936a8a488c8f967cf42b9b5ef8c30b3a989e345 (diff) | |
download | bcm5719-llvm-1800d823de1ec72d827f12ca340d5ca2d2a81510.tar.gz bcm5719-llvm-1800d823de1ec72d827f12ca340d5ca2d2a81510.zip |
Also fold (A+B) == A -> B == 0 when the add is commuted.
llvm-svn: 125411
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index a24d4ca7eb3..c34e698e3e7 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2351,12 +2351,14 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { Constant::getNullValue(B->getType())); // (A+B) == A -> B == 0 - if (match(Op0, m_Add(m_Specific(Op1), m_Value(B)))) + if (match(Op0, m_Add(m_Specific(Op1), m_Value(B))) || + match(Op0, m_Add(m_Value(B), m_Specific(Op1)))) return new ICmpInst(I.getPredicate(), B, Constant::getNullValue(B->getType())); // A == (A+B) -> B == 0 - if (match(Op1, m_Add(m_Specific(Op0), m_Value(B)))) + if (match(Op1, m_Add(m_Specific(Op0), m_Value(B))) || + match(Op1, m_Add(m_Value(B), m_Specific(Op0)))) return new ICmpInst(I.getPredicate(), B, Constant::getNullValue(B->getType())); |