[llvm] [RISCV] Add optimization for memset inline (PR #146673)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 10:04:29 PST 2025
================
@@ -25011,8 +25015,23 @@ EVT RISCVTargetLowering::getOptimalMemOpType(
// a large scalar constant and instead use vmv.v.x/i to do the
// broadcast. For everything else, prefer ELenVT to minimize VL and thus
// maximize the chance we can encode the size in the vsetvli.
- MVT ELenVT = MVT::getIntegerVT(Subtarget.getELen());
- MVT PreferredVT = (Op.isMemset() && !Op.isZeroMemset()) ? MVT::i8 : ELenVT;
+ // If Op size is greater than LMUL8 memory operation, we don't support inline
+ // of memset. Return EVT based on Op size to avoid redundant splitting and
+ // merging operations if Op size is no greater than LMUL8 memory operation.
+ if (Op.isMemset()) {
+ if (!Op.isZeroMemset())
+ return EVT::getVectorVT(Context, MVT::i8, Op.size());
+ if (Op.size() >
+ Subtarget.getMaxLMULForFixedLengthVectors() * MinVLenInBytes)
+ return MVT::Other;
+ if (Subtarget.hasVInstructionsI64() && Op.size() % 8 == 0)
+ return EVT::getVectorVT(Context, MVT::i64, Op.size() / 8);
----------------
topperc wrote:
Do we need to check alignment for any of these types?
https://github.com/llvm/llvm-project/pull/146673
More information about the llvm-commits
mailing list