[llvm] 4baeed8 - [InstCombine] Remove unnecessary handling of non-canonical predicates (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 01:42:32 PDT 2023


Author: Nikita Popov
Date: 2023-10-25T10:42:25+02:00
New Revision: 4baeed803faab948db2363e439cd9aa501cd0d5b

URL: https://github.com/llvm/llvm-project/commit/4baeed803faab948db2363e439cd9aa501cd0d5b
DIFF: https://github.com/llvm/llvm-project/commit/4baeed803faab948db2363e439cd9aa501cd0d5b.diff

LOG: [InstCombine] Remove unnecessary handling of non-canonical predicates (NFCI)

ule/uge with a constant will be converted to ult/ugt, so there is
no need to handle these variants.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 5137734b63b3b72..fcf69f6171a6435 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -5906,29 +5906,6 @@ static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal,
     }
     return nullptr;
 
-  case ICmpInst::ICMP_UGE:
-    // Recognize pattern:
-    //   mulval = mul(zext A, zext B)
-    //   cmp uge mulval, max+1
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) {
-      APInt MaxVal = APInt::getOneBitSet(CI->getBitWidth(), MulWidth);
-      if (MaxVal.eq(CI->getValue()))
-        break; // Recognized
-    }
-    return nullptr;
-
-  case ICmpInst::ICMP_ULE:
-    // Recognize pattern:
-    //   mulval = mul(zext A, zext B)
-    //   cmp ule mulval, max
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) {
-      APInt MaxVal = APInt::getMaxValue(MulWidth);
-      MaxVal = MaxVal.zext(CI->getBitWidth());
-      if (MaxVal.eq(CI->getValue()))
-        break; // Recognized
-    }
-    return nullptr;
-
   case ICmpInst::ICMP_ULT:
     // Recognize pattern:
     //   mulval = mul(zext A, zext B)
@@ -5998,13 +5975,11 @@ static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal,
     Inverse = true;
     break;
   case ICmpInst::ICMP_UGT:
-  case ICmpInst::ICMP_UGE:
     if (I.getOperand(0) == MulVal)
       break;
     Inverse = true;
     break;
   case ICmpInst::ICMP_ULT:
-  case ICmpInst::ICMP_ULE:
     if (I.getOperand(1) == MulVal)
       break;
     Inverse = true;


        


More information about the llvm-commits mailing list