[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


================
@@ -16367,6 +16372,26 @@ static SDValue combinePExtTruncate(SDNode *N, SelectionDAG &DAG,
 
   SDValue Op = N0.getOperand(0);
   unsigned ShAmtVal = C->getZExtValue();
+  unsigned EltBits = VecVT.getScalarSizeInBits();
+
+  // Check for rounding pattern: (add (mul ...), round_const)
+  bool IsRounding = false;
+  if (Op.getOpcode() == ISD::ADD && (EltBits == 16 || EltBits == 32)) {
+    SDValue AddRHS = Op.getOperand(1);
+    if (AddRHS.getOpcode() == ISD::BUILD_VECTOR) {
----------------
topperc wrote:

We don't need this opcode check AND the dyn_cast below. All BUILD_VECTOR nodes will dyn_cast to BuildVectorSDNode.

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


More information about the llvm-commits mailing list