[llvm] [RISCV] Add codegen support for SATI and USATI. (PR #189532)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 10:54:40 PDT 2026


================
@@ -21455,6 +21456,53 @@ static SDValue performSHLCombine(SDNode *N,
                      Passthru, Mask, VL);
 }
 
+static SDValue combineMinMaxToSat(SDNode *N,
+                                  TargetLowering::DAGCombinerInfo &DCI,
+                                  const RISCVSubtarget &Subtarget) {
+  if (!DCI.isAfterLegalizeDAG())
+    return SDValue();
+
+  if (!Subtarget.hasStdExtP())
+    return SDValue();
+
+  EVT VT = N->getValueType(0);
+
+  if (VT != Subtarget.getXLenVT())
+    return SDValue();
+
+  SDValue N0 = N->getOperand(0);
+
+  if ((N0.getOpcode() != ISD::SMIN && N0.getOpcode() != ISD::SMAX) ||
+      !isa<ConstantSDNode>(N->getOperand(1)) ||
+      !isa<ConstantSDNode>(N->getOperand(1)))
----------------
topperc wrote:

One of those is supposed to be on N0. Guess I need more tests.

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


More information about the llvm-commits mailing list