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

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 06:06:53 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)) {
----------------
pfusik wrote:

Done, thanks!

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


More information about the llvm-commits mailing list