[llvm] [DAGCombiner] Fold vector subtraction if above threshold to `umin` (PR #148834)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 05:14:33 PDT 2025


================
@@ -4093,6 +4093,26 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
       return N0;
   }
 
+  // (sub x, ([v]select (ult x, y), 0, y)) -> (umin x, (sub x, y))
+  // (sub x, ([v]select (uge x, y), y, 0)) -> (umin x, (sub x, y))
+  if (N1.hasOneUse() && hasUMin(VT)) {
----------------
arsenm wrote:

Most TLI.isOperationLegal checks should be isOperationLegalOrCustom 

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


More information about the llvm-commits mailing list