Also fold (A+B) == A -> B == 0 when the add is commuted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125411 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index a24d4ca..c34e698 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2351,12 +2351,14 @@
                           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()));