[llvm] [RISCV] Fold subtraction if above threshold to Zbb `minu` (PR #134235)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 3 09:05:16 PDT 2025


================
@@ -14895,6 +14895,19 @@ static SDValue performSUBCombine(SDNode *N, SelectionDAG &DAG,
   if (SDValue V = combineSubShiftToOrcB(N, DAG, Subtarget))
     return V;
 
+  if (Subtarget.hasStdExtZbb()) {
+    // fold (sub x, (select (ult x, y), 0, y)) -> (umin x, (sub x, y))
----------------
topperc wrote:

Oops, I meant `(sub x, (select (uge x, y), y, 0)?` So only inverting the condition and swapping the select order

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


More information about the llvm-commits mailing list