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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

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

commit r11-8191-ga3317f7b3c02907a122f89879e5b6e90c386e64d
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Thu Apr 15 11:37:38 2021 +0100

    c: Don't drop vector attributes that affect type identity [PR98852]

    <arm_neon.h> types are distinct from GNU vector types in at least
    their mangling.  However, there used to be nothing explicit in the
    VECTOR_TYPE itself to indicate the difference: we simply treated them
    as distinct TYPE_MAIN_VARIANTs.  This caused problems like the ones
    reported in PR95726.

    The fix for that PR was to add type attributes to the <arm_neon.h>
    types, in order to maintain the distinction between them and GNU
    vectors.  However, this in turn caused PR98852, where c_common_type
    would unconditionally drop the attributes on the source types.
    This meant that:

       <arm_neon.h> vector + <arm_neon.h> vector

    had a GNU vector type rather than an <arm_neon.h> vector type.

    See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96377#c2 for
    Jakub's analysis of the history of this c_common_type code.
    TBH I'm not sure which case the build_type_attribute_variant
    code is handling, but I think we should at least avoid dropping
    attributes that affect type identity.

    I've tried to audit the C and target-specific attributes to look
    for other types that might be affected by this, but I couldn't
    see any.  We are only dealing with:

      gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
                  || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
                  || code1 == INTEGER_TYPE);

    which excludes most affects_type_identity attributes.  The closest
    was s390_vector_bool, but the handler for that attribute changes
    the type node and drops the attribute itself (*no_add_attrs = true).

    I put the main list handling into a separate function
    (remove_attributes_matching) because a later patch will need it
    for something else.

    gcc/
            PR c/98852
            * attribs.h (affects_type_identity_attributes): Declare.
            * attribs.c (remove_attributes_matching): New function.
            (affects_type_identity_attributes): Likewise.

    gcc/c/
            PR c/98852
            * c-typeck.c (c_common_type): Do not drop attributes that
            affect type identity.

    gcc/testsuite/
            PR c/98852
            * gcc.target/aarch64/advsimd-intrinsics/pr98852.c: New test.

Reply via email to