]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/69053 (ICE in build_vector_from_val)
authorRichard Biener <rguenther@suse.de>
Tue, 12 Jan 2016 11:41:16 +0000 (11:41 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 12 Jan 2016 11:41:16 +0000 (11:41 +0000)
2016-01-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/69053
* tree-vect-loop.c (get_initial_def_for_reduction): Properly
convert initial value for cond reductions.

* g++.dg/torture/pr69053.C: New testcase.

From-SVN: r232263

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr69053.C [new file with mode: 0644]
gcc/tree-vect-loop.c

index 708fab405e571566d819cb3bd4a458eca83b74e9..afc1b277cc9494dc5f8719309384f1c4f5afe7ef 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69053
+       * tree-vect-loop.c (get_initial_def_for_reduction): Properly
+       convert initial value for cond reductions.
+
 2016-01-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/69007
index 7829a4e45fcd0c44b965c06e59e1e14a2b557b36..d827695a3da6789d71766e6dbc319f2cf66fbc0e 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69053
+       * g++.dg/torture/pr69053.C: New testcase.
+
 2016-01-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/69168
diff --git a/gcc/testsuite/g++.dg/torture/pr69053.C b/gcc/testsuite/g++.dg/torture/pr69053.C
new file mode 100644 (file)
index 0000000..4ca986c
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// { dg-additional-options "-march=core-avx2" { target x86_64-*-* i?86-*-* } }
+struct A {
+    int *elem[1];
+};
+int a, d, e;
+A *b;
+int *c;
+int main()
+{
+  int *f = 0;
+  for (; e; e++)
+    if (b->elem[e])
+      f = c;
+  if (f)
+    a = d;
+}
index 706a25d2d0d65f87c29ef914c5b00b643b474362..0933e7eb770550ec90dd2898503c7c077954b993 100644 (file)
@@ -4075,10 +4075,10 @@ get_initial_def_for_reduction (gimple *stmt, tree init_val,
   tree *elts;
   int i;
   bool nested_in_vect_loop = false;
-  tree init_value;
   REAL_VALUE_TYPE real_init_val = dconst0;
   int int_init_val = 0;
   gimple *def_stmt = NULL;
+  gimple_seq stmts = NULL;
 
   gcc_assert (vectype);
   nunits = TYPE_VECTOR_SUBPARTS (vectype);
@@ -4107,16 +4107,6 @@ get_initial_def_for_reduction (gimple *stmt, tree init_val,
       return vect_create_destination_var (init_val, vectype);
     }
 
-  if (TREE_CONSTANT (init_val))
-    {
-      if (SCALAR_FLOAT_TYPE_P (scalar_type))
-        init_value = build_real (scalar_type, TREE_REAL_CST (init_val));
-      else
-        init_value = build_int_cst (scalar_type, TREE_INT_CST_LOW (init_val));
-    }
-  else
-    init_value = init_val;
-
   switch (code)
     {
       case WIDEN_SUM_EXPR:
@@ -4193,7 +4183,10 @@ get_initial_def_for_reduction (gimple *stmt, tree init_val,
                break;
              }
          }
-       init_def = build_vector_from_val (vectype, init_value);
+       init_val = gimple_convert (&stmts, TREE_TYPE (vectype), init_val);
+       if (! gimple_seq_empty_p (stmts))
+         gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
+       init_def = build_vector_from_val (vectype, init_val);
        break;
 
       default: