PR middle-end/PR44706
authorJan Hubicka <jh@suse.cz>
Wed, 30 Jun 2010 16:51:36 +0000 (18:51 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 30 Jun 2010 16:51:36 +0000 (16:51 +0000)
PR middle-end/PR44706
* ipa-split (split_function): Refine conditions when to use DECL_RESULT
to return the value.
* gcc.dg/tree-ssa/ipa-split-4.c: New testcase.

From-SVN: r161615

gcc/ChangeLog
gcc/ipa-split.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ipa-split-4.c [new file with mode: 0644]

index ff37f0cbcb4ca3700ae046d9866a56fdae282fa0..b19c28998ae299bdc02e6f3981c9c6bd60e437f3 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-30  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/PR44706
+       * ipa-split (split_function): Refine conditions when to use DECL_RESULT
+       to return the value.
+
 2010-06-30  Michael Matz  <matz@suse.de>
 
        PR bootstrap/44699
index ae784b6dd779ce8310b81086dc6b63621ca93720..289a7b38beb804a683fe59b99789086f3edeed2d 100644 (file)
@@ -931,6 +931,13 @@ split_function (struct split_point *split_point)
          if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
            {
              retval = DECL_RESULT (current_function_decl);
+
+             /* We use temporary register to hold value when aggregate_value_p
+                is false.  Similarly for DECL_BY_REFERENCE we must avoid extra
+                copy.  */
+             if (!aggregate_value_p (retval, TREE_TYPE (current_function_decl))
+                 && !DECL_BY_REFERENCE (retval))
+               retval = create_tmp_reg (TREE_TYPE (retval), NULL);
              if (is_gimple_reg (retval))
                retval = make_ssa_name (retval, call);
              gimple_call_set_lhs (call, retval);
index 136c37b57a900d5779ea7da573dd872472cd2ce9..d9e9a4025f9399d4006e7de127dbb021345dbce8 100644 (file)
@@ -1,3 +1,7 @@
+2010-06-30  Jan Hubicka  <jh@suse.cz>
+
+       * gcc.dg/tree-ssa/ipa-split-4.c: New testcase.
+
 2010-06-30  Michael Matz  <matz@suse.de>
 
        PR bootstrap/44699
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ipa-split-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ipa-split-4.c
new file mode 100644 (file)
index 0000000..c2c3960
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-fnsplit" } */
+int make_me_big (void);
+
+int
+split_me (int a)
+{
+  if (__builtin_expect(a<10, 1))
+    {
+      abort ();
+    }
+  else
+    {
+      make_me_big ();
+      make_me_big ();
+      make_me_big ();
+      make_me_big ();
+      return a+1;
+    }
+}
+
+main()
+{
+  return split_me (0)+split_me(1)+split_me(2);
+}
+/* { dg-final { scan-tree-dump-times "Splitting function" 1 "fnsplit"} } */
+/* { dg-final { cleanup-tree-dump "fnsplit" } } */