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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <tnfch...@gcc.gnu.org>:

https://gcc.gnu.org/g:1216460e7023cd8ec49933866107417c70e933c9

commit r14-10040-g1216460e7023cd8ec49933866107417c70e933c9
Author: Tamar Christina <tamar.christ...@arm.com>
Date:   Fri Apr 19 15:22:13 2024 +0100

    middle-end: refactory vect_recog_absolute_difference to simplify flow
[PR114769]

    Hi All,

    As the reporter in PR114769 points out the control flow for the abd
detection
    is hard to follow.  This is because vect_recog_absolute_difference has two
    different ways it can return true.

    1. It can return true when the widening operation is matched, in which case
       unprom is set, half_type is not NULL and diff_stmt is not set.

    2. It can return true when the widening operation is not matched, but the
stmt
       being checked is a minus.  In this case unprom is not set, half_type is
set
       to NULL and diff_stmt is set.  This because to get to diff_stmt you have
to
       dig through the abs statement and any possible promotions.

    This however leads to complicated uses of the function at the call sites as
the
    exact semantic needs to be known to use it safely.

    vect_recog_absolute_difference has two callers:

    1. vect_recog_sad_pattern where if you return true with unprom not set,
then
       *half_type will be NULL.  The call to vect_supportable_direct_optab_p
will
       always reject it since there's no vector mode for NULL.  Note that if
looking
       at the dump files, the convention in the dump files have always been
that we
       first indicate that a pattern could possibly be recognize and then check
that
       it's supported.

       This change somewhat incorrectly makes the diagnostic message get
printed for
       "invalid" patterns.

    2. vect_recog_abd_pattern, where if half_type is NULL, it then uses
diff_stmt to
       set them.

    This refactors the code, it now only has 1 success condition, and diff_stmt
is
    always set to the minus statement in the abs if there is one.

    The function now only returns success if the widening minus is found, in
which
    case unprom and half_type set.

    This then leaves it up to the caller to decide if they want to do anything
with
    diff_stmt.

    Thanks,
    Tamar

    gcc/ChangeLog:

            PR tree-optimization/114769
            * tree-vect-patterns.cc:
            (vect_recog_absolute_difference): Have only one success condition.
            (vect_recog_abd_pattern): Handle further checks if
            vect_recog_absolute_difference fails.

Reply via email to