This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Handle variable-length vectors in compute_record_mode


On Wed, Sep 18, 2019 at 8:52 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> This patch makes compute_record_mode handle SVE vectors in the
> same way as it would handle fixed-length vectors.  There should
> be no change in behaviour for other targets.
>
> This is needed for the SVE equivalent of arm_neon.h types like
> int8x8x2_t (i.e. a pair of int8x8_ts).
>
> Tested on aarch64-linux-gnu with SVE (with and without follow-on
> patches) and x86_64-linux-gnu.  OK to install?

OK.

Richard.

> Richard
>
>
> 2019-09-18  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * stor-layout.c (compute_record_mode): Operate on poly_uint64
>         sizes instead of uhwi sizes.
>
> Index: gcc/stor-layout.c
> ===================================================================
> --- gcc/stor-layout.c   2019-08-20 09:52:22.522737142 +0100
> +++ gcc/stor-layout.c   2019-09-18 07:49:59.796102474 +0100
> @@ -1811,7 +1811,8 @@ compute_record_mode (tree type)
>       line.  */
>    SET_TYPE_MODE (type, BLKmode);
>
> -  if (! tree_fits_uhwi_p (TYPE_SIZE (type)))
> +  poly_uint64 type_size;
> +  if (!poly_int_tree_p (TYPE_SIZE (type), &type_size))
>      return;
>
>    /* A record which has any BLKmode members must itself be
> @@ -1822,20 +1823,21 @@ compute_record_mode (tree type)
>        if (TREE_CODE (field) != FIELD_DECL)
>         continue;
>
> +      poly_uint64 field_size;
>        if (TREE_CODE (TREE_TYPE (field)) == ERROR_MARK
>           || (TYPE_MODE (TREE_TYPE (field)) == BLKmode
>               && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field))
>               && !(TYPE_SIZE (TREE_TYPE (field)) != 0
>                    && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))))
> -         || ! tree_fits_uhwi_p (bit_position (field))
> +         || !tree_fits_poly_uint64_p (bit_position (field))
>           || DECL_SIZE (field) == 0
> -         || ! tree_fits_uhwi_p (DECL_SIZE (field)))
> +         || !poly_int_tree_p (DECL_SIZE (field), &field_size))
>         return;
>
>        /* If this field is the whole struct, remember its mode so
>          that, say, we can put a double in a class into a DF
>          register instead of forcing it to live in the stack.  */
> -      if (simple_cst_equal (TYPE_SIZE (type), DECL_SIZE (field))
> +      if (known_eq (field_size, type_size)
>           /* Partial int types (e.g. __int20) may have TYPE_SIZE equal to
>              wider types (e.g. int32), despite precision being less.  Ensure
>              that the TYPE_MODE of the struct does not get set to the partial
> @@ -1855,7 +1857,6 @@ compute_record_mode (tree type)
>       For UNION_TYPE, if the widest field is MODE_INT then use that mode.
>       If the widest field is MODE_PARTIAL_INT, and the union will be passed
>       by reference, then use that mode.  */
> -  poly_uint64 type_size;
>    if ((TREE_CODE (type) == RECORD_TYPE
>         || (TREE_CODE (type) == UNION_TYPE
>            && (GET_MODE_CLASS (mode) == MODE_INT
> @@ -1864,7 +1865,6 @@ compute_record_mode (tree type)
>                        (pack_cumulative_args (0),
>                         function_arg_info (type, mode, /*named=*/false)))))))
>        && mode != VOIDmode
> -      && poly_int_tree_p (TYPE_SIZE (type), &type_size)
>        && known_eq (GET_MODE_BITSIZE (mode), type_size))
>      ;
>    else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]