[llvm] [ExpandMemCmp] Use m_SpecificInt to simplify code. NFC (PR #121532)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 16:42:26 PST 2025
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/121532
None
>From de080772d10d2c22f4d801a39713aa6825dafbd0 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 2 Jan 2025 16:41:14 -0800
Subject: [PATCH] [ExpandMemCmp] Use m_SpecificInt to simplify code. NFC
---
llvm/lib/CodeGen/ExpandMemCmp.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/ExpandMemCmp.cpp b/llvm/lib/CodeGen/ExpandMemCmp.cpp
index f8ca7e370f6ef9..e18b2d3c31691c 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