tree-optimization/96974 - avoid ICE by replacing assert with standard failure
authorStam Markianos-Wright <stam.markianos-wright@arm.com>
Thu, 25 Mar 2021 15:29:41 +0000 (15:29 +0000)
committerStam Markianos-Wright <stam.markianos-wright@arm.com>
Thu, 25 Mar 2021 15:29:41 +0000 (15:29 +0000)
Minor patch to add a graceful exit in the rare case where an invalid
combination of TYPE_VECTOR_SUBPARTS for nunits_vectype and
*stmt_vectype_out is reached in vect_get_vector_types_for_stmt.

This resolves the ICE seen in PR tree-optimization/96974, however the issue
of correctly handling this rare vectorization combination is left for a
later patch.

Bootstrapped and reg-tested on aarch64-linux-gnu.

2021-03-25  Stam Markianos-Wright  <stam.markianos-wright@arm.com>

gcc/ChangeLog:

PR tree-optimization/96974
* tree-vect-stmts.c (vect_get_vector_types_for_stmt): Replace assert
with graceful exit.

gcc/testsuite/ChangeLog:

PR tree-optimization/96974
* g++.target/aarch64/sve/pr96974.C: New test.

gcc/testsuite/g++.target/aarch64/sve/pr96974.C [new file with mode: 0644]
gcc/tree-vect-stmts.c

diff --git a/gcc/testsuite/g++.target/aarch64/sve/pr96974.C b/gcc/testsuite/g++.target/aarch64/sve/pr96974.C
new file mode 100644 (file)
index 0000000..363241d
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -march=armv8.2-a+sve -fdisable-tree-fre4 -fdump-tree-slp-details" } */
+
+float a;
+int
+b ()
+{ return __builtin_lrintf(a); }
+
+struct c {
+  float d;
+    c() {
+      for (int e = 0; e < 9; e++)
+       coeffs[e] = d ? b() : 0;
+    }
+    int coeffs[10];
+} f;
+
+/* { dg-final { scan-tree-dump "Not vectorized: Incompatible number of vector subparts between" "slp1" } } */
index d791d3a..4c01e82 100644 (file)
@@ -12148,8 +12148,12 @@ vect_get_vector_types_for_stmt (vec_info *vinfo, stmt_vec_info stmt_info,
        }
     }
 
-  gcc_assert (multiple_p (TYPE_VECTOR_SUBPARTS (nunits_vectype),
-                         TYPE_VECTOR_SUBPARTS (*stmt_vectype_out)));
+  if (!multiple_p (TYPE_VECTOR_SUBPARTS (nunits_vectype),
+                  TYPE_VECTOR_SUBPARTS (*stmt_vectype_out)))
+    return opt_result::failure_at (stmt,
+                                  "Not vectorized: Incompatible number "
+                                  "of vector subparts between %T and %T\n",
+                                  nunits_vectype, *stmt_vectype_out);
 
   if (dump_enabled_p ())
     {