[llvm] [DAGCombiner] Fold subtraction if above a constant threshold to `umin` (PR #135194)
Mikael Holmén via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 01:33:09 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)
----------------
mikaelholmen wrote:
@pfusik: What if the add results in poison?
select blocks poison but umin doesn't(?). We've seen a downstream miscompile that we think is because of this.
https://github.com/llvm/llvm-project/pull/135194
More information about the llvm-commits
mailing list