From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28008 invoked by alias); 29 Aug 2005 13:13:34 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 27958 invoked by uid 48); 29 Aug 2005 13:13:19 -0000 Date: Mon, 29 Aug 2005 13:15:00 -0000 Message-ID: <20050829131319.27957.qmail@sourceware.org> From: "rguenth at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050813080257.23372.guillaume.melquiond@ens-lyon.fr> References: <20050813080257.23372.guillaume.melquiond@ens-lyon.fr> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/23372] [4.0/4.1 Regression] Temporary aggregate copy not elided when passing parameters by value X-Bugzilla-Reason: CC X-SW-Source: 2005-08/txt/msg03302.txt.bz2 List-Id: ------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-29 13:13 ------- One possibility would be to hack out-of-ssa to coalesce single use variables with their defs in the case of aggregates. The real fix would involve expanding to rtl from ssa, so we have this information ready and need not create these useless memcpy's. Or whatever solution is more "correct" here ("fixing" the frontends will not work for the second testcase until we allow function calls as arguments in gimple). Anyway, here's the hack that passed bootstrapping and regtesting for C and C++ with only some tr1 tests failing: Index: gimplify.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v retrieving revision 2.113.2.11 diff -c -3 -p -r2.113.2.11 gimplify.c *** gimplify.c 16 Aug 2005 22:16:52 -0000 2.113.2.11 --- gimplify.c 29 Aug 2005 12:04:33 -0000 *************** gimplify_target_expr (tree *expr_p, tree *** 3628,3633 **** --- 3628,3641 ---- if (init) { + /* Try to avoid the temporary if possible. */ + if (TREE_CODE (init) == INDIRECT_REF + && !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); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23372