Fix unguarded use of tree_to_shwi in tree-ssa-sccvn.c
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 28 Aug 2018 10:42:42 +0000 (10:42 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 28 Aug 2018 10:42:42 +0000 (10:42 +0000)
Fixes many testsuite failures for SVE.

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.

From-SVN: r263914

gcc/ChangeLog
gcc/tree-ssa-sccvn.c

index a357b4ba448db0c6c05aa6c9710457cfa3e48fae..0e2f9d013c34861479c76c677f597e1d3f581b54 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-28  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * 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.
+
 2018-08-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/87117
index 9277de0cbdc535687e0916c16cfd25b619f357cf..39ad0c595ac2ec6909b3391250cb3809f92ad052 100644 (file)
@@ -1409,16 +1409,16 @@ fully_constant_vn_reference_p (vn_reference_t ref)
   /* 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;