aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2006-01-30 13:46:30 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2006-01-30 13:46:30 +0000
commiteb73a69a1538e24fcf39f108d22d324ae8cd1d90 (patch)
tree4075aa6a3ca867fcf1bacbb54f9f28ccc7e2699c
parent4e852d1f9d56a1325bffcf4512dfebdd3837d97c (diff)
downloadgcc-eb73a69a1538e24fcf39f108d22d324ae8cd1d90.zip
gcc-eb73a69a1538e24fcf39f108d22d324ae8cd1d90.tar.gz
gcc-eb73a69a1538e24fcf39f108d22d324ae8cd1d90.tar.bz2
re PR c++/23372 (Temporary aggregate copy not elided when passing parameters by value)
2006-01-30 Richard Guenther <rguenther@suse.de> PR c++/23372 * gimplify.c (gimplify_target_expr): Handle easy cases without creating a temporary. * gcc.dg/pr23372-1.C: New testcase. From-SVN: r110396
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimplify.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr23372-1.c10
4 files changed, 30 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 99b6f9f..dcd3684 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-30 Richard Guenther <rguenther@suse.de>
+
+ PR c++/23372
+ * gimplify.c (gimplify_target_expr): Handle easy cases
+ without creating a temporary.
+
2006-01-30 Nathan Sidwell <nathan@codesourcery.com>
* vec.h (safe_grow): Remove duplicated line.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index cb1b95e..8761609 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4053,6 +4053,15 @@ gimplify_target_expr (tree *expr_p, tree *pre_p, tree *post_p)
if (init)
{
+ /* Try to avoid the temporary if possible. */
+ if (TREE_CODE (init) == INDIRECT_REF
+ && !TREE_SIDE_EFFECTS (init)
+ && !TARGET_EXPR_CLEANUP (targ))
+ {
+ *expr_p = init;
+ return GS_OK;
+ }
+
/* TARGET_EXPR temps aren't part of the enclosing block, so add it
to the temps list. */
gimple_add_tmp_var (temp);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5d9b87b..c7b6411 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-30 Richard Guenther <rguenther@suse.de>
+
+ PR c++/23372
+ * gcc.dg/pr23372-1.C: New testcase.
+
2006-01-29 Diego Novillo <dnovillo@redhat.com>
* gcc.dg/gomp/pr25874.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr23372-1.c b/gcc/testsuite/gcc.dg/pr23372-1.c
new file mode 100644
index 0000000..1414947
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr23372-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+struct A {
+ int a[1000];
+};
+void f(struct A);
+void g(struct A *a) { f(*a); }
+
+/* { dg-final { scan-assembler-times "memcpy" 1 } } */