[llvm-branch-commits] [llvm] [RISCV] Support non-power-of-2 types when expanding memcmp (PR #114971)
Luke Lau via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jun 13 03:09:22 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);
----------------
lukel97 wrote:
Just checking, if MF8 isn't supported for the ELEN, e.g. MF8 on zve32x, `getContainerForFixedLengthVector` in RISCVISelLowering will still lower it into the next largest LMUL so this should be fine right?
https://github.com/llvm/llvm-project/pull/114971
More information about the llvm-branch-commits
mailing list