[llvm] r281627 - [InstCombine] remove duplicated fold ; NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 10:01:18 PDT 2016


Author: spatel
Date: Thu Sep 15 12:01:17 2016
New Revision: 281627

URL: http://llvm.org/viewvc/llvm-project?rev=281627&view=rev
Log:
[InstCombine] remove duplicated fold ; NFCI

This pattern is matched in foldICmpBinOpEqualityWithConstant() and already works
with vectors too. I changed some comments over there to point out the current 
location. The tests for this transform are currently in 'sub.ll'.

Note that the remaining folds in this block all require a sub too, so they should
get grouped with the other icmp(sub) patterns.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=281627&r1=281626&r2=281627&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu Sep 15 12:01:17 2016
@@ -1423,11 +1423,6 @@ Instruction *InstCombiner::foldICmpWithC
   // The following transforms are only worth it if the only user of the subtract
   // is the icmp.
   if (X->hasOneUse()) {
-    // (icmp ne/eq (sub A B) 0) -> (icmp ne/eq A, B)
-    if (Cmp.isEquality() && CI->isZero() &&
-        match(X, m_Sub(m_Value(A), m_Value(B))))
-      return new ICmpInst(Pred, A, B);
-
     // (icmp sgt (sub nsw A B), -1) -> (icmp sge A, B)
     if (Pred == ICmpInst::ICMP_SGT && CI->isAllOnesValue() &&
         match(X, m_NSWSub(m_Value(A), m_Value(B))))
@@ -2522,11 +2517,11 @@ Instruction *InstCombiner::foldICmpBinOp
     if (BO->hasOneUse()) {
       const APInt *BOC;
       if (match(BOp0, m_APInt(BOC))) {
-        // Replace ((sub A, B) != C) with (B != A-C) if A & C are constants.
+        // Replace ((sub BOC, B) != C) with (B != BOC-C).
         Constant *SubC = ConstantExpr::getSub(cast<Constant>(BOp0), RHS);
         return new ICmpInst(Pred, BOp1, SubC);
       } else if (*C == 0) {
-        // Replace ((sub A, B) != 0) with (A != B)
+        // Replace ((sub A, B) != 0) with (A != B).
         return new ICmpInst(Pred, BOp0, BOp1);
       }
     }




More information about the llvm-commits mailing list