[llvm] r306779 - Reduce the complexity of the signbit/branch test functions.

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 18:35:31 PDT 2017


Author: echristo
Date: Thu Jun 29 18:35:31 2017
New Revision: 306779

URL: http://llvm.org/viewvc/llvm-project?rev=306779&view=rev
Log:
Reduce the complexity of the signbit/branch test functions.

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=306779&r1=306778&r2=306779&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu Jun 29 18:35:31 2017
@@ -112,10 +112,10 @@ static bool subWithOverflow(Constant *&R
 
 /// Given an icmp instruction, return true if any use of this comparison is a
 /// branch on sign bit comparison.
-static bool isBranchOnSignBitCheck(ICmpInst &I, bool isSignBit) {
+static bool hasBranchUse(ICmpInst &I) {
   for (auto *U : I.users())
     if (isa<BranchInst>(U))
-      return isSignBit;
+      return true;
   return false;
 }
 
@@ -1448,7 +1448,7 @@ Instruction *InstCombiner::foldICmpWithC
     // of a test and branch. So we avoid canonicalizing in such situations
     // because test and branch instruction has better branch displacement
     // than compare and branch instruction.
-    if (!isBranchOnSignBitCheck(Cmp, IsSignBit) && !Cmp.isEquality()) {
+    if (!(IsSignBit && hasBranchUse(Cmp)) && !Cmp.isEquality()) {
       if (auto *AI = Intersection.getSingleElement())
         return new ICmpInst(ICmpInst::ICMP_EQ, X, Builder->getInt(*AI));
       if (auto *AD = Difference.getSingleElement())




More information about the llvm-commits mailing list