diff options
author | Anders Carlsson <andersca@mac.com> | 2011-01-30 22:01:13 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2011-01-30 22:01:13 +0000 |
commit | 77bc49e5e2e2a5e549d65bc0bedd86ff3df6b161 (patch) | |
tree | 7f93923534f5f181e5ec3155cab6bbadc9d4caa9 /lib/Transforms/InstCombine/InstCombineCompares.cpp | |
parent | 8352062e52eed6e50786fdb89f5e601fdcbe0d90 (diff) |
Recognize and simplify
(A+B) == A -> B == 0
A == (A+B) -> B == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124567 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCompares.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index fe436bce21..8c5e7e48c4 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2341,7 +2341,17 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { if (match(Op1, m_Sub(m_Specific(Op0), m_Value(B)))) return new ICmpInst(I.getPredicate(), B, Constant::getNullValue(B->getType())); - + + // (A+B) == A -> B == 0 + if (match(Op0, m_Add(m_Specific(Op1), m_Value(B)))) + 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)))) + return new ICmpInst(I.getPredicate(), B, + Constant::getNullValue(B->getType())); + // (X&Z) == (Y&Z) -> (X^Y) & Z == 0 if (Op0->hasOneUse() && Op1->hasOneUse() && match(Op0, m_And(m_Value(A), m_Value(B))) && |