[llvm] 715dcb2 - [ExpandMemCmp] Use m_SpecificInt to simplify code. NFC (#121532)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 3 09:19:57 PST 2025


Author: Craig Topper
Date: 2025-01-03T09:19:54-08:00
New Revision: 715dcb2310a4378fdf324cd3d3b47d6f160842aa

URL: https://github.com/llvm/llvm-project/commit/715dcb2310a4378fdf324cd3d3b47d6f160842aa
DIFF: https://github.com/llvm/llvm-project/commit/715dcb2310a4378fdf324cd3d3b47d6f160842aa.diff

LOG: [ExpandMemCmp] Use m_SpecificInt to simplify code. NFC (#121532)

Added: 
    

Modified: 
    llvm/lib/CodeGen/ExpandMemCmp.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ExpandMemCmp.cpp b/llvm/lib/CodeGen/ExpandMemCmp.cpp
index 6dc3e04ac802c2..cc75a01c6477a2 100644
--- a/llvm/lib/CodeGen/ExpandMemCmp.cpp
+++ b/llvm/lib/CodeGen/ExpandMemCmp.cpp
@@ -669,15 +669,15 @@ Value *MemCmpExpansion::getMemCmpOneBlock() {
   if (CI->hasOneUser()) {
     auto *UI = cast<Instruction>(*CI->user_begin());
     CmpPredicate Pred = ICmpInst::Predicate::BAD_ICMP_PREDICATE;
-    uint64_t Shift;
     bool NeedsZExt = false;
     // This is a special case because instead of checking if the result is less
     // than zero:
     //    bool result = memcmp(a, b, NBYTES) < 0;
     // Compiler is clever enough to generate the following code:
     //    bool result = memcmp(a, b, NBYTES) >> 31;
-    if (match(UI, m_LShr(m_Value(), m_ConstantInt(Shift))) &&
-        Shift == (CI->getType()->getIntegerBitWidth() - 1)) {
+    if (match(UI,
+              m_LShr(m_Value(),
+                     m_SpecificInt(CI->getType()->getIntegerBitWidth() - 1)))) {
       Pred = ICmpInst::ICMP_SLT;
       NeedsZExt = true;
     } else {


        


More information about the llvm-commits mailing list