IBM Z: Use tree_fits_uhwi_p in vector_alignment hook
authorAndreas Krebbel <krebbel@linux.ibm.com>
Tue, 5 Nov 2019 13:21:06 +0000 (13:21 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Tue, 5 Nov 2019 13:21:06 +0000 (13:21 +0000)
This fixes an ICE in gcc.dg/attr-vector_size.c testcase.

gcc/ChangeLog:

2019-11-05  Andreas Krebbel  <krebbel@linux.ibm.com>

* config/s390/s390.c (s390_vector_alignment): Check if the value
fits into uhwi before using it.

From-SVN: r277829

gcc/ChangeLog
gcc/config/s390/s390.c

index c281cc84ef9e7be882d0018c932bd2ec8108bcfb..b3d97c27bbd49121e2402325b91bca8f89ec968f 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-05  Andreas Krebbel  <krebbel@linux.ibm.com>
+
+       * config/s390/s390.c (s390_vector_alignment): Check if the value
+       fits into uhwi before using it.
+
 2019-11-05  Martin Liska  <mliska@suse.cz>
 
        * symbol-summary.h: Use ggc_delete.
index 151b80da0b38358bd336069bb1272688f24f934f..ff0b43c2c29b0fcad9b4806379999cf46d59bc45 100644 (file)
@@ -16075,13 +16075,19 @@ s390_support_vector_misalignment (machine_mode mode ATTRIBUTE_UNUSED,
 static HOST_WIDE_INT
 s390_vector_alignment (const_tree type)
 {
+  tree size = TYPE_SIZE (type);
+
   if (!TARGET_VX_ABI)
     return default_vector_alignment (type);
 
   if (TYPE_USER_ALIGN (type))
     return TYPE_ALIGN (type);
 
-  return MIN (64, tree_to_shwi (TYPE_SIZE (type)));
+  if (tree_fits_uhwi_p (size)
+      && tree_to_uhwi (size) < BIGGEST_ALIGNMENT)
+    return tree_to_uhwi (size);
+
+  return BIGGEST_ALIGNMENT;
 }
 
 /* Implement TARGET_CONSTANT_ALIGNMENT.  Alignment on even addresses for