[llvm] [DAGCombiner] Fold smax(X, -1)/smin(X, 0) to bitwise shift forms (PR #206242)
Aayush Shrivastava via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 30 04:32:57 PDT 2026
iamaayushrivastava wrote:
> > > // smax(x, 0) can be done by doing tli.hasandnot and then doing the
> > > smax(X, 0) = and(X, ~ashr(X, BW-1))
> > > Though maybe I can just add that in a followup PR, but it is like one difference from the smin version...
> >
> >
> > Great idea! Happy to add `smax(X, 0) = and(X, ~ashr(X, BW-1))` in this PR if you'd prefer, just let me know!
>
> Sure! That's it after this.
Done. Added `smax(X, 0) → and(X, ~ashr(X, BW-1))` gated on `hasAndNot` (fires on AArch64 with BIC and x86+BMI with ANDN, skipped otherwise to avoid 3-instruction sequences). Thanks for the suggestion!
https://github.com/llvm/llvm-project/pull/206242
More information about the llvm-commits
mailing list