Fix ICE in vectorizable_live_operation
authorRichard Biener <rguenther@suse.de>
Thu, 15 Oct 2020 08:58:41 +0000 (10:58 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 15 Oct 2020 09:49:38 +0000 (11:49 +0200)
This fixes the case where the insertion iterator for the live stmt
is the end of a BB by adjusting the dominance query to the definition
of the def we're substituting.

2020-10-15  Richard Biener  <rguenther@suse.de>

* tree-vect-loop.c (vectorizable_live_operation): Adjust
dominance query.

* gcc.dg/vect/bb-slp-52.c: New testcase.

gcc/testsuite/gcc.dg/vect/bb-slp-52.c [new file with mode: 0644]
gcc/tree-vect-loop.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-52.c b/gcc/testsuite/gcc.dg/vect/bb-slp-52.c
new file mode 100644 (file)
index 0000000..5194af8
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+int a, e;
+void g(float);
+typedef struct {
+  float b, c;
+} d;
+d f;
+void h(double i, double j) {
+  if (a && e)
+    return;
+  f.b = j;
+  f.c = i;
+  g(i);
+}
index 0a315e222260980a95450c70b29eac28b3a7bd53..991fd4572298448c5d074f87a4ed318f0a3c9db6 100644 (file)
@@ -8395,8 +8395,11 @@ vectorizable_live_operation (vec_info *vinfo,
               were not code-generated yet so it is not too bad.
               ???  In fact we'd likely want to avoid this situation
               in the first place.  */
-           if (gimple_code (use_stmt) != GIMPLE_PHI
-               && !vect_stmt_dominates_stmt_p (gsi_stmt (*gsi), use_stmt))
+           if (TREE_CODE (new_tree) == SSA_NAME
+               && !SSA_NAME_IS_DEFAULT_DEF (new_tree)
+               && gimple_code (use_stmt) != GIMPLE_PHI
+               && !vect_stmt_dominates_stmt_p (SSA_NAME_DEF_STMT (new_tree),
+                                               use_stmt))
              {
                enum tree_code code = gimple_assign_rhs_code (use_stmt);
                gcc_assert (code == CONSTRUCTOR