[llvm] [DAGCombiner] Fold subtraction if above a constant threshold to `umin` (PR #135194)
Piotr Fusik via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 02:39:30 PDT 2025
================
@@ -12074,6 +12078,17 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
if (SDValue NewSel = SimplifySelect(DL, N0, N1, N2))
return NewSel;
+
+ // (select (ugt x, C), (add x, ~C), x) -> (umin (add x, ~C), x)
----------------
pfusik wrote:
Do you have a reproducer?
If it's `add nuw/nsw`, I think the solution would be to drop `nuw/nsw` during this transform.
https://github.com/llvm/llvm-project/pull/135194
More information about the llvm-commits
mailing list