[llvm] [RISCV] Fold (vslide1up undef, v, (extract_elt x, 0)) into (vslideup x, v, 1) (PR #154847)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 1 22:09:41 PDT 2025
================
@@ -21117,6 +21117,37 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
return N->getOperand(0);
break;
}
+ case RISCVISD::VSLIDE1UP_VL:
+ case RISCVISD::VFSLIDE1UP_VL: {
+ using namespace SDPatternMatch;
+ SDValue SrcVec;
+ SDLoc DL(N);
+ MVT VT = N->getSimpleValueType(0);
+ // If the scalar we're sliding in was extracted from the first element of a
+ // vector, we can use that vector as the passthru in a normal slideup of 1.
+ // This saves us an extract_element instruction (i.e. vfmv.f.s, vmv.x.s).
+ if (N->getOperand(0).isUndef() &&
+ sd_match(
+ N->getOperand(2),
+ m_OneUse(m_AnyOf(m_ExtractElt(m_Value(SrcVec), m_Zero()),
+ m_Node(RISCVISD::VMV_X_S, m_Value(SrcVec)))))) {
+ MVT SrcVecVT = SrcVec.getSimpleValueType();
+ // Adapt the value type of source vector.
+ if (SrcVecVT.isFixedLengthVector()) {
----------------
lukel97 wrote:
I thought all the RISCVISD nodes had to be in scalable containers to begin with? Is there somewhere where we're creating fixed length vslide1up_vls?
https://github.com/llvm/llvm-project/pull/154847
More information about the llvm-commits
mailing list