[llvm-branch-commits] [llvm] [RISCV] Support non-power-of-2 types when expanding memcmp (PR #114971)

Pengcheng Wang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 13 03:16:49 PDT 2025


================
@@ -2954,20 +2954,13 @@ RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
   }
 
   if (IsZeroCmp && ST->hasVInstructions()) {
-    unsigned RealMinVLen = ST->getRealMinVLen();
-    // Support Fractional LMULs if the lengths are larger than XLen.
-    // TODO: Support non-power-of-2 types.
-    for (unsigned FLMUL = 8; FLMUL >= 2; FLMUL /= 2) {
-      unsigned Len = RealMinVLen / FLMUL;
-      if (Len > ST->getXLen())
-        Options.LoadSizes.insert(Options.LoadSizes.begin(), Len / 8);
-    }
-    for (unsigned LMUL = 1; LMUL <= ST->getMaxLMULForFixedLengthVectors();
-         LMUL *= 2) {
-      unsigned Len = RealMinVLen * LMUL;
-      if (Len > ST->getXLen())
-        Options.LoadSizes.insert(Options.LoadSizes.begin(), Len / 8);
-    }
+    unsigned VLenB = ST->getRealMinVLen() / 8;
+    // The minimum size should be the maximum bytes between `VLen * LMUL_MF8`
+    // and `XLen * 2`.
+    unsigned MinSize = std::max(VLenB / 8, ST->getXLen() * 2 / 8);
----------------
wangpc-pp wrote:

I remember I limited it with a reason but I forget the reason since it is 8 months ago. I will check.

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


More information about the llvm-branch-commits mailing list