[llvm] [PatternMatch] Allow `m_ConstantInt` to match integer splats (PR #153692)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 15 02:14:45 PDT 2025


================
@@ -1013,12 +1013,13 @@ struct bind_const_intval_ty {
   bind_const_intval_ty(uint64_t &V) : VR(V) {}
 
   template <typename ITy> bool match(ITy *V) const {
-    if (const auto *CV = dyn_cast<ConstantInt>(V))
-      if (CV->getValue().ule(UINT64_MAX)) {
-        VR = CV->getZExtValue();
-        return true;
-      }
-    return false;
+    const APInt *ConstInt;
+    if (!apint_match(ConstInt, /*AllowPoison=*/false).match(V))
+      return false;
+    if (ConstInt->ugt(UINT64_MAX))
----------------
nikic wrote:

Should check getActiveBits() instead.

https://github.com/llvm/llvm-project/pull/153692


More information about the llvm-commits mailing list