diff mbox series

Fix unguarded use of tree_to_shwi in tree-ssa-sccvn.c

Message ID 871saisrkv.fsf@arm.com
State New
Headers show
Series Fix unguarded use of tree_to_shwi in tree-ssa-sccvn.c | expand

Commit Message

Richard Sandiford Aug. 28, 2018, 10:39 a.m. UTC
Fixes many testsuite failures for SVE.

Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf
and x86_64-linux-gnu.  OK to install?

Richard


2018-08-28  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-ssa-sccvn.c (fully_constant_vn_reference_p): Fix unguarded
	use of tree_to_shwi.  Remove duplicated test for the size being
	a whole number of bytes.

Comments

Richard Biener Aug. 28, 2018, 10:40 a.m. UTC | #1
On Tue, Aug 28, 2018 at 12:39 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Fixes many testsuite failures for SVE.
>
> Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf
> and x86_64-linux-gnu.  OK to install?

OK.

Richard.

> Richard
>
>
> 2018-08-28  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Fix unguarded
>         use of tree_to_shwi.  Remove duplicated test for the size being
>         a whole number of bytes.
>
> Index: gcc/tree-ssa-sccvn.c
> ===================================================================
> --- gcc/tree-ssa-sccvn.c        2018-08-28 11:38:22.000000000 +0100
> +++ gcc/tree-ssa-sccvn.c        2018-08-28 11:38:22.676512354 +0100
> @@ -1409,16 +1409,16 @@ fully_constant_vn_reference_p (vn_refere
>    /* Simplify reads from constants or constant initializers.  */
>    else if (BITS_PER_UNIT == 8
>            && COMPLETE_TYPE_P (ref->type)
> -          && is_gimple_reg_type (ref->type)
> -          && (!INTEGRAL_TYPE_P (ref->type)
> -              || TYPE_PRECISION (ref->type) % BITS_PER_UNIT == 0))
> +          && is_gimple_reg_type (ref->type))
>      {
>        poly_int64 off = 0;
>        HOST_WIDE_INT size;
>        if (INTEGRAL_TYPE_P (ref->type))
>         size = TYPE_PRECISION (ref->type);
> -      else
> +      else if (tree_fits_shwi_p (TYPE_SIZE (ref->type)))
>         size = tree_to_shwi (TYPE_SIZE (ref->type));
> +      else
> +       return NULL_TREE;
>        if (size % BITS_PER_UNIT != 0
>           || size > MAX_BITSIZE_MODE_ANY_MODE)
>         return NULL_TREE;
diff mbox series

Patch

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	2018-08-28 11:38:22.000000000 +0100
+++ gcc/tree-ssa-sccvn.c	2018-08-28 11:38:22.676512354 +0100
@@ -1409,16 +1409,16 @@  fully_constant_vn_reference_p (vn_refere
   /* Simplify reads from constants or constant initializers.  */
   else if (BITS_PER_UNIT == 8
 	   && COMPLETE_TYPE_P (ref->type)
-	   && is_gimple_reg_type (ref->type)
-	   && (!INTEGRAL_TYPE_P (ref->type)
-	       || TYPE_PRECISION (ref->type) % BITS_PER_UNIT == 0))
+	   && is_gimple_reg_type (ref->type))
     {
       poly_int64 off = 0;
       HOST_WIDE_INT size;
       if (INTEGRAL_TYPE_P (ref->type))
 	size = TYPE_PRECISION (ref->type);
-      else
+      else if (tree_fits_shwi_p (TYPE_SIZE (ref->type)))
 	size = tree_to_shwi (TYPE_SIZE (ref->type));
+      else
+	return NULL_TREE;
       if (size % BITS_PER_UNIT != 0
 	  || size > MAX_BITSIZE_MODE_ANY_MODE)
 	return NULL_TREE;