[llvm] [RISCV][llvm] Support BUILD_VECTOR codegen for P extension (PR #169083)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 11:15:30 PST 2025


================
@@ -4434,6 +4435,29 @@ static SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
 
   SDLoc DL(Op);
 
+  if (Subtarget.isRV32() && Subtarget.enablePExtCodeGen()) {
+    if (VT != MVT::v4i8)
+      return SDValue();
+
+    // <4 x i8> BUILD_VECTOR a, b, c, d -> PACK(PPACK.DH pair(a, b), pair(c, d))
+    SDValue Val0 = DAG.getNode(ISD::BITCAST, DL, MVT::v4i8, Op->getOperand(0));
----------------
topperc wrote:

These should be SCALAR_TO_VECTOR. Other optimizations understand that as a transition from scalar to vector better than a bitcast.

https://github.com/llvm/llvm-project/pull/169083


More information about the llvm-commits mailing list