[llvm] [RISCV] Directly use pack* in build_vector lowering (PR #98084)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 15:22:53 PDT 2024
================
@@ -3933,30 +3948,34 @@ static SDValue lowerBuildVectorViaPacking(SDValue Op, SelectionDAG &DAG,
// Produce [B,A] packed into a type twice as wide. Note that all
// scalars are XLenVT, possibly masked (see below).
MVT XLenVT = Subtarget.getXLenVT();
+ SDValue Mask = DAG.getConstant(
+ APInt::getLowBitsSet(XLenVT.getSizeInBits(), ElemSizeInBits), DL, XLenVT);
auto pack = [&](SDValue A, SDValue B) {
// Bias the scheduling of the inserted operations to near the
// definition of the element - this tends to reduce register
// pressure overall.
SDLoc ElemDL(B);
+ if (Subtarget.hasStdExtZbkb())
+ // Note that we're relying on the high bits of the result being
+ // don't care. For PACKW, the result is *sign* extended.
+ return SDValue(
+ DAG.getMachineNode(getPACKOpcode(ElemSizeInBits * 2, Subtarget),
+ ElemDL, XLenVT, A, B),
+ 0);
+
+ A = DAG.getNode(ISD::AND, SDLoc(A), XLenVT, A, Mask);
+ B = DAG.getNode(ISD::AND, SDLoc(B), XLenVT, B, Mask);
SDValue ShtAmt = DAG.getConstant(ElemSizeInBits, ElemDL, XLenVT);
+ SDNodeFlags Flags;
+ Flags.setDisjoint(true);
----------------
topperc wrote:
I'm ok with it.
https://github.com/llvm/llvm-project/pull/98084
More information about the llvm-commits
mailing list