On Sat, Jul 31, 2021 at 9:56 AM Roger Sayle <ro...@nextmovesoftware.com> wrote:
>
>
> Many thanks again to Jakub Jelinek for a speedy fix for PR 101642.
> Interestingly, that test case "bswap16(x) ? : x" also reveals a
> missed optimization opportunity.  The resulting "x ? bswap(x) : 0"
> can be further simplified to just bswap(x).
>
> Conveniently, tree-ssa-phiopt.c already recognizes/optimizes the
> related "x ? popcount(x) : 0", so this patch simply makes that
> transformation make general, additionally handling bswap, parity,
> ffs and clrsb.  All of the required infrastructure is already
> present thanks to Jakub previously adding support for clz/ctz.
> To reflect this generalization, the name of the function is changed
> from cond_removal_in_popcount_clz_ctz_pattern to the hopefully
> equally descriptive cond_removal_in_builtin_zero_pattern.
>
> The following patch has been tested on x86_64-pc-linux-gnu with a
> "make bootstrap" and "make -k check" with no new failures.
>
> Ok for mainline?

OK.

Thanks,
Richard.

>
> 2021-07-31  Roger Sayle  <ro...@nextmovesoftware.com>
>
> gcc/ChangeLog
>         * tree-ssa-phiopt.c (cond_removal_in_builtin_zero_pattern):
>         Renamed from cond_removal_in_popcount_clz_ctz_pattern.
>         Add support for BSWAP, FFS, PARITY and CLRSB builtins.
>         (tree_ssa_phiop_worker): Update call to function above.
>
> gcc/testuite/ChangeLog
>         * gcc.dg/tree-ssa/phi-opt-25.c: New test case.
>
>
> Roger
> --
> Roger Sayle
> NextMove Software
> Cambridge, UK
>

Reply via email to