[clang] [llvm] [RISCV][P-ext] Support Packed Narrowing Clip Pair (PR #215779)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 00:05:32 PDT 2026


================
@@ -12302,6 +12283,77 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
     return DAG.getNode(Opc, DL, Op.getValueType(), Op.getOperand(1),
                        Op.getOperand(2));
   }
+  case Intrinsic::riscv_pnclipp:
+  case Intrinsic::riscv_pnclipup: {
+    EVT VT = Op.getValueType();
+    SDValue Rs1 = Op.getOperand(1);
+    SDValue Rs2 = Op.getOperand(2);
+    unsigned Opc = IntNo == Intrinsic::riscv_pnclipp ? RISCVISD::PNCLIPP
+                                                     : RISCVISD::PNCLIPUP;
+
+    if (Subtarget.is64Bit()) {
+      if (VT == MVT::v2i32 && !Rs1.getValueType().isVector()) {
+        unsigned WOpc = IntNo == Intrinsic::riscv_pnclipp
+                            ? RISCVISD::PNCLIPP_W
+                            : RISCVISD::PNCLIPUP_W;
+        return DAG.getNode(WOpc, DL, VT, Rs1, Rs2);
+      }
+      return DAG.getNode(Opc, DL, VT, Rs1, Rs2);
+    }
+
+    auto BuildPair = [&](SDValue Lo, SDValue Hi, MVT PairVT) {
+      return DAG.getNode(RISCVISD::BuildPairGPRVec, DL, PairVT, Lo, Hi);
+    };
+
+    MVT XLenVT = Subtarget.getXLenVT();
+    if (VT == MVT::v4i8) {
+      SDValue Pair = BuildPair(Rs1, Rs2, MVT::v4i16);
+      SDVTList VTs = DAG.getVTList(MVT::v4i8);
+      unsigned ClipOpc = IntNo == Intrinsic::riscv_pnclipp ? RISCV::PNCLIPI_B
+                                                           : RISCV::PNCLIPIU_B;
+      SDValue Ops[] = {Pair, DAG.getTargetConstant(0, DL, MVT::i32)};
+      return SDValue(DAG.getMachineNode(ClipOpc, DL, VTs, Ops), 0);
----------------
TelGome wrote:

done. Switch to lowering from generic node and add pat patterns.

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


More information about the llvm-commits mailing list