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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:17c9c7c10a70d18dea5849d11a4fa382d3817fa1

commit r15-5888-g17c9c7c10a70d18dea5849d11a4fa382d3817fa1
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Dec 3 11:17:49 2024 +0100

    tree-ssanames, match.pd: get_nonzero_bits/with_*_nonzero_bits* cleanups and
improvements [PR117420]

    The following patch implements the with_*_nonzero_bits* cleanups and
    improvements I was talking about.

    get_nonzero_bits is extended to also handle BIT_AND_EXPR (as a tree or
    as SSA_NAME with BIT_AND_EXPR def_stmt), new function is added for the
    bits known to be set (get_known_nonzero_bits) and the match.pd predicates
    are renamed and adjusted, so that there is no confusion on which one to
    use (one is named and documented to be internal), changed so that it can be
    used only as a simple predicate, not match some operands, and that it
doesn't
    try to match twice for the GIMPLE case (where SSA_NAME with integral or
pointer
    type matches, but SSA_NAME with BIT_AND_EXPR def_stmt matched differently).
    Furthermore, get_nonzero_bits just returns the all bits set (or
    get_known_nonzero_bits no bits set) fallback if the argument isn't a
    SSA_NAME (nor INTEGER_CST or whatever the functions handle explicitly).

    2024-12-03  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/117420
            * tree-ssanames.h (get_known_nonzero_bits): Declare.
            * tree-ssanames.cc (get_nonzero_bits): New wrapper function.  Move
old
            definition to ...
            (get_nonzero_bits_1): ... here, add static.  Change widest_int in
            function comment to wide_int.
            (get_known_nonzero_bits_1, get_known_nonzero_bits): New functions.
            * match.pd (with_possible_nonzero_bits2): Rename to ...
            (with_possible_nonzero_bits): ... this.  Guard the bit_and case
with
            #if GENERIC.  Change to a normal match predicate without
parameters.
            Rename the old with_possible_nonzero_bits match to ...
            (with_possible_nonzero_bits_1): ... this.
            (with_certain_nonzero_bits2): Remove.
            (with_known_nonzero_bits_1, with_known_nonzero_bits): New match
            predicates.
            (X == C (or X & Z == Y | C) is impossible if ~nonzero(X) & C != 0):
            Use with_known_nonzero_bits@0 instead of
            (with_certain_nonzero_bits2 @1), use with_possible_nonzero_bits@0
            instead of (with_possible_nonzero_bits2 @0) and
            get_known_nonzero_bits (@1) instead of wi::to_wide (@1).

            * gcc.dg/tree-ssa/pr117420.c: New test.

Reply via email to