re PR c++/60836 (invalid PHI argument and ICE in verify_gimple)
authorRichard Biener <rguenther@suse.de>
Thu, 17 Apr 2014 08:12:58 +0000 (08:12 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 17 Apr 2014 08:12:58 +0000 (08:12 +0000)
2014-04-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/60836
* tree-vect-loop.c (vect_create_epilog_for_reduction): Force
initial PHI args to be gimple values.

* g++.dg/vect/pr60836.cc: New testcase.

From-SVN: r209468

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

index a8664ea9836d89682ad1a5060073c7f113be9ae0..abfe3186d2e4d7bcf678c8b819c31686e3fdbd05 100644 (file)
@@ -1,3 +1,9 @@
+2014-04-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60836
+       * tree-vect-loop.c (vect_create_epilog_for_reduction): Force
+       initial PHI args to be gimple values.
+
 2014-04-17   Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/60841
index 7e9b599766f211cb2115a561724df0b848d7410b..f180aef57a1e158ea6d759745529255945cbc0ab 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60836
+       * g++.dg/vect/pr60836.cc: New testcase.
+
 2014-04-17   Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/60841
diff --git a/gcc/testsuite/g++.dg/vect/pr60836.cc b/gcc/testsuite/g++.dg/vect/pr60836.cc
new file mode 100644 (file)
index 0000000..83bb183
--- /dev/null
@@ -0,0 +1,39 @@
+// { dg-do compile }
+
+int a, b;
+typedef double (*NormFunc) (const int &);
+int &
+max (int &p1, int &p2)
+{
+  if (p1 < p2)
+    return p2;
+  return p1;
+}
+
+struct A
+{
+  int operator      () (int p1, int p2)
+    {
+      return max (p1, p2);
+    }
+};
+template < class, class > double
+norm_ (const int &)
+{
+  char c, d;
+  A e;
+  for (; a; a++)
+    {
+      b = e (b, d);
+      b = e (b, c);
+    }
+}
+
+void
+norm ()
+{
+  static NormFunc f = norm_ < int, A >;
+  f = 0;
+}
+
+// { dg-final { cleanup-tree-dump "vect" } }
index 7ec079a83749232e7fa10b889680b3a5b832fbc7..7f4209346bc5a2e57e640a7fde19d5e885e2a0ac 100644 (file)
@@ -3952,8 +3952,12 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple stmt,
   /* Set phi nodes arguments.  */
   FOR_EACH_VEC_ELT (reduction_phis, i, phi)
     {
-      tree vec_init_def = vec_initial_defs[i];
-      tree def = vect_defs[i];
+      tree vec_init_def, def;
+      gimple_seq stmts;
+      vec_init_def = force_gimple_operand (vec_initial_defs[i], &stmts,
+                                          true, NULL_TREE);
+      gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
+      def = vect_defs[i];
       for (j = 0; j < ncopies; j++)
         {
           /* Set the loop-entry arg of the reduction-phi.  */