Fix ICE in tree-switch-conversion.
authorMartin Liska <mliska@suse.cz>
Mon, 21 Sep 2020 10:50:37 +0000 (12:50 +0200)
committerMartin Liska <mliska@suse.cz>
Mon, 21 Sep 2020 11:52:03 +0000 (13:52 +0200)
With SVE we can end up with:
switch (POLY_INT_CST [2, 2]) <default: <L2> [INV], case 2: <L3> [INV], case 4: <L3> [INV]>
which is fine to expand and we can remove the assert.

gcc/ChangeLog:

PR tree-optimization/96915
* tree-switch-conversion.c (switch_conversion::expand): Accept
also integer constants.

gcc/testsuite/ChangeLog:

PR tree-optimization/96915
* gcc.target/aarch64/sve/pr96915.c: New test.

gcc/testsuite/gcc.target/aarch64/sve/pr96915.c [new file with mode: 0644]
gcc/tree-switch-conversion.c

diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr96915.c b/gcc/testsuite/gcc.target/aarch64/sve/pr96915.c
new file mode 100644 (file)
index 0000000..fae4cd4
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR tree-optimization/96915 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=armv8.2-a+sve" } */
+
+#pragma GCC aarch64 "arm_sve.h"
+void b() {
+  switch (svcntd())
+  case 2:
+  case 4:
+    b();
+}
index 4b435941d127cfbca0965661cd9063d2850f2e9a..186411ff3c42b04fe30885e0e9df220200e1b7a6 100644 (file)
@@ -984,9 +984,6 @@ switch_conversion::expand (gswitch *swtch)
      during gimplification).  */
   gcc_checking_assert (TREE_TYPE (m_index_expr) != error_mark_node);
 
-  /* A switch on a constant should have been optimized in tree-cfg-cleanup.  */
-  gcc_checking_assert (!TREE_CONSTANT (m_index_expr));
-
   /* Prefer bit test if possible.  */
   if (tree_fits_uhwi_p (m_range_size)
       && bit_test_cluster::can_be_handled (tree_to_uhwi (m_range_size), m_uniq)