[llvm] [llvm][RISCV] Support rounding mulh for P extension codegen (PR #171593)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 22 09:35:36 PST 2025


================
@@ -16401,14 +16426,24 @@ static SDValue combinePExtTruncate(SDNode *N, SelectionDAG &DAG,
       return SDValue();
     break;
   case ISD::MUL:
-    // PMULHSU: shift amount must be element size, only for i16/i32
-    unsigned EltBits = VecVT.getScalarSizeInBits();
+    // PMULH*/PMULHR*: shift amount must be element size, only for i16/i32
     if (ShAmtVal != EltBits || (EltBits != 16 && EltBits != 32))
       return SDValue();
-    if (LHSIsSExt && RHSIsZExt)
-      Opc = RISCVISD::PMULHSU;
-    else
-      return SDValue();
+    if (IsRounding) {
+      if (LHSIsSExt && RHSIsSExt)
+        Opc = RISCVISD::PMULHR;
+      else if (LHSIsZExt && RHSIsZExt)
+        Opc = RISCVISD::PMULHRU;
+      else if (LHSIsSExt && RHSIsZExt)
----------------
topperc wrote:

What about the commuted case?

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


More information about the llvm-commits mailing list