[llvm] 9864162 - [InstCombine] Drop redundant fold for and/or of icmp eq/ne (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 11 11:25:47 PST 2021


Author: Nikita Popov
Date: 2021-11-11T20:25:40+01:00
New Revision: 986416251b354bb1b45870617050e72919ff2759

URL: https://github.com/llvm/llvm-project/commit/986416251b354bb1b45870617050e72919ff2759
DIFF: https://github.com/llvm/llvm-project/commit/986416251b354bb1b45870617050e72919ff2759.diff

LOG: [InstCombine] Drop redundant fold for and/or of icmp eq/ne (NFCI)

This handles a special case of foldAndOrOfICmpsUsingRanges()
with two equality predicates.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 8b7f7f33b9b1..017f7aaa2a7f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -774,20 +774,6 @@ foldAndOrOfEqualityCmpsWithConstants(ICmpInst *LHS, ICmpInst *RHS,
     return Builder.CreateICmp(Pred, Or, ConstantInt::get(X->getType(), *C2));
   }
 
-  // Special case: get the ordering right when the values wrap around zero.
-  // Ie, we assumed the constants were unsigned when swapping earlier.
-  if (C1->isZero() && C2->isAllOnes())
-    std::swap(C1, C2);
-
-  if (*C1 == *C2 - 1) {
-    // (X == 13 || X == 14) --> X - 13 <=u 1
-    // (X != 13 && X != 14) --> X - 13  >u 1
-    // An 'add' is the canonical IR form, so favor that over a 'sub'.
-    Value *Add = Builder.CreateAdd(X, ConstantInt::get(X->getType(), -(*C1)));
-    auto NewPred = JoinedByAnd ? ICmpInst::ICMP_UGT : ICmpInst::ICMP_ULE;
-    return Builder.CreateICmp(NewPred, Add, ConstantInt::get(X->getType(), 1));
-  }
-
   return nullptr;
 }
 


        


More information about the llvm-commits mailing list