[llvm] [InstCombine] Canonicalize `smax(smin(X, MinC), MaxC) -> smin(smax(X, MaxC), MinC)` (PR #136665)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 02:39:37 PDT 2025
el-ev wrote:
> 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.
The pattern has been handled in DAGCombiner by you... That's amazing!
#88505
https://github.com/llvm/llvm-project/pull/136665
More information about the llvm-commits
mailing list