[llvm] [InstCombine] Canonicalize `smax(smin(X, MinC), MaxC) -> smin(smax(X, MaxC), MinC)` (PR #136665)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 01:51:04 PDT 2025
https://github.com/dtcxzyw commented:
BTW, the downside of this canonicalization is that clamp idioms may be broken by another `smin -> umin` canonicalization.
Consider the following pattern:
```
%min = smin(X, MinC)
%max = smax(%min, PosMaxC) where MinC s>= PosMaxC
```
After this canonicalization, we got:
```
%max = smax(X, PosMaxC)
%min = smin(%max, MinC) ->
%min = umin(%max, MinC) since we know both %max and MinC are non-negative.
```
Please check if this pattern is handled in DAGCombine, or if this transform is reverted somewhere.
https://github.com/llvm/llvm-project/pull/136665
More information about the llvm-commits
mailing list