aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
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 /gcc/gimplify.c
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
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c9
1 files changed, 9 insertions, 0 deletions
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);