re PR tree-optimization/33458 (ICE "PHI def is not a GIMPLE value")
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Nov 2007 08:29:48 +0000 (09:29 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 6 Nov 2007 08:29:48 +0000 (09:29 +0100)
PR tree-optimization/33458
* tree-inline.c (copy_phis_for_bb): If PHI arg substitution creates
!is_gimple_val PHI argument, gimplify it and insert it on edge.

* g++.dg/opt/inline12.C: New test.

From-SVN: r129921

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/inline12.C [new file with mode: 0644]
gcc/tree-inline.c

index 38237bf3d8811fac9197ea2fe2735a86da637f66..02195432374db54ae68abf50abfd4ceccdcdc1b0 100644 (file)
@@ -1,5 +1,9 @@
 2007-11-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/33458
+       * tree-inline.c (copy_phis_for_bb): If PHI arg substitution creates
+       !is_gimple_val PHI argument, gimplify it and insert it on edge.
+
        PR tree-optimization/33993
        * tree-vect-transform.c (vect_get_constant_vectors): Use build_vector
        rather than build_constructor_from_list if all list values are
index 54974ace16e7c673cb2dca23d2cf35f73a6e7265..8b04b28901fc7227a04f0e0eebb734da0cfd018f 100644 (file)
@@ -1,5 +1,8 @@
 2007-11-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/33458
+       * g++.dg/opt/inline12.C: New test.
+
        PR tree-optimization/33993
        * gcc.c-torture/compile/20071105-1.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/inline12.C b/gcc/testsuite/g++.dg/opt/inline12.C
new file mode 100644 (file)
index 0000000..d9eae30
--- /dev/null
@@ -0,0 +1,32 @@
+// PR tree-optimization/33458
+// { dg-do compile }
+// { dg-options "-O" }
+
+inline void
+foo (int *p, int n)
+{
+  for (; n > 0; --n, ++p)
+    *p = 0;
+}
+
+struct A
+{
+  int x[2];
+  A () { foo (x, 2); }
+};
+
+inline A
+getA ()
+{
+  return A ();
+}
+
+struct B
+{
+  A a;
+  B ();
+};
+
+B::B () : a (getA ())
+{
+}
index ac8b5b5a400096ca855aed6d004e7ad9313db0d9..e7abeff00932a3663389952a3107f46b891db6d9 100644 (file)
@@ -1193,6 +1193,17 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id)
 
              walk_tree (&new_arg, copy_body_r, id, NULL);
              gcc_assert (new_arg);
+             /* With return slot optimization we can end up with
+                non-gimple (foo *)&this->m, fix that here.  */
+             if (TREE_CODE (new_arg) != SSA_NAME
+                 && TREE_CODE (new_arg) != FUNCTION_DECL
+                 && !is_gimple_val (new_arg))
+               {
+                 tree stmts = NULL_TREE;
+                 new_arg = force_gimple_operand (new_arg, &stmts,
+                                                 true, NULL);
+                 bsi_insert_on_edge_immediate (new_edge, stmts);
+               }
              add_phi_arg (new_phi, new_arg, new_edge);
            }
        }