[llvm] [RISCV] Use vwsll.vi/vx + vwadd.wv to lower vector.interleave when Zvbb enabled. (PR #67521)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 27 08:23:10 PDT 2023
================
@@ -4264,24 +4264,37 @@ static SDValue getWideningInterleave(SDValue EvenV, SDValue OddV,
auto [Mask, VL] = getDefaultVLOps(VecVT, VecContainerVT, DL, DAG, Subtarget);
SDValue Passthru = DAG.getUNDEF(WideContainerVT);
- // Widen EvenV and OddV with 0s and add one copy of OddV to EvenV with
- // vwaddu.vv
- SDValue Interleaved = DAG.getNode(RISCVISD::VWADDU_VL, DL, WideContainerVT,
- EvenV, OddV, Passthru, Mask, VL);
-
- // Then get OddV * by 2^(VecVT.getScalarSizeInBits() - 1)
- SDValue AllOnesVec = DAG.getSplatVector(
- VecContainerVT, DL, DAG.getAllOnesConstant(DL, Subtarget.getXLenVT()));
- SDValue OddsMul = DAG.getNode(RISCVISD::VWMULU_VL, DL, WideContainerVT, OddV,
- AllOnesVec, Passthru, Mask, VL);
-
- // Add the two together so we get
- // (OddV * 0xff...ff) + (OddV + EvenV)
- // = (OddV * 0x100...00) + EvenV
- // = (OddV << VecVT.getScalarSizeInBits()) + EvenV
- // Note the ADD_VL and VLMULU_VL should get selected as vwmaccu.vx
- Interleaved = DAG.getNode(RISCVISD::ADD_VL, DL, WideContainerVT, Interleaved,
- OddsMul, Passthru, Mask, VL);
+ SDValue Interleaved;
+ if (Subtarget.hasStdExtZvbb()) {
+ // Interleaved = (OddV << VecVT.getScalarSizeInBits()) + EvenV.
+ SDValue OffsetVec =
+ DAG.getSplatVector(VecContainerVT, DL,
+ DAG.getConstant(VecVT.getScalarSizeInBits(), DL,
+ Subtarget.getXLenVT()));
+ Interleaved = DAG.getNode(RISCVISD::VWSLL_VL, DL, WideContainerVT, OddV,
+ OffsetVec, Passthru, Mask, VL);
+ Interleaved = DAG.getNode(RISCVISD::VWADD_W_VL, DL, WideContainerVT,
----------------
topperc wrote:
Shouldn't it be VWADDU_W_VL? We need the lower bits to be zero extended.
https://github.com/llvm/llvm-project/pull/67521
More information about the llvm-commits
mailing list