https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101642

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sa...@gcc.gnu.org>:

https://gcc.gnu.org/g:f9fcf754825a1e01033336f84c18690aaa971a6f

commit r12-2657-gf9fcf754825a1e01033336f84c18690aaa971a6f
Author: Roger Sayle <ro...@nextmovesoftware.com>
Date:   Mon Aug 2 13:27:53 2021 +0100

    Optimize x ? bswap(x) : 0 in tree-ssa-phiopt

    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.

    2021-08-02  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/testsuite/ChangeLog
            * gcc.dg/tree-ssa/phi-opt-25.c: New test case.

Reply via email to