From bd42a56bb4d7a4a39b08eceee7eff87d3264a9c2 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Tue, 27 May 2008 14:28:02 +0000 Subject: [PATCH] re PR middle-end/36326 (gimplification of aggregate copies introduces extra aggregate copy) PR middle-end/36326 * tree-gimple.c (is_gimple_mem_rhs): Remove work-around for non-BLKmode types. * tree-tailcall.c (find_tail_calls): Don't mark calls storing into memory as tail calls. From-SVN: r136033 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-gimple.c | 9 ++------- gcc/tree-tailcall.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b0ccae4f652..33ef156a46a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2008-05-27 Michael Matz + + PR middle-end/36326 + * tree-gimple.c (is_gimple_mem_rhs): Remove work-around for + non-BLKmode types. + * tree-tailcall.c (find_tail_calls): Don't mark calls storing + into memory as tail calls. + 2008-05-27 Richard Guenther PR tree-optimization/36339 diff --git a/gcc/tree-gimple.c b/gcc/tree-gimple.c index da84777725a..2334e126343 100644 --- a/gcc/tree-gimple.c +++ b/gcc/tree-gimple.c @@ -113,13 +113,8 @@ bool is_gimple_mem_rhs (tree t) { /* If we're dealing with a renamable type, either source or dest must be - a renamed variable. Also force a temporary if the type doesn't need - to be stored in memory, since it's cheap and prevents erroneous - tailcalls (PR 17526). */ - if (is_gimple_reg_type (TREE_TYPE (t)) - || (TYPE_MODE (TREE_TYPE (t)) != BLKmode - && (TREE_CODE (t) != CALL_EXPR - || ! aggregate_value_p (t, t)))) + a renamed variable. */ + if (is_gimple_reg_type (TREE_TYPE (t))) return is_gimple_val (t); else return is_gimple_formal_tmp_rhs (t); diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 7481de59325..09a2eafe119 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -429,6 +429,20 @@ find_tail_calls (basic_block bb, struct tailcall **ret) return; } + /* If the LHS of our call is not just a simple register, we can't + transform this into a tail or sibling call. This situation happens, + in (e.g.) "*p = foo()" where foo returns a struct. In this case + we won't have a temporary here, but we need to carry out the side + effect anyway, so tailcall is impossible. + + ??? In some situations (when the struct is returned in memory via + invisible argument) we could deal with this, e.g. by passing 'p' + itself as that argument to foo, but it's too early to do this here, + and expand_call() will not handle it anyway. If it ever can, then + we need to revisit this here, to allow that situation. */ + if (ass_var && !is_gimple_reg (ass_var)) + return; + /* We found the call, check whether it is suitable. */ tail_recursion = false; func = get_callee_fndecl (call); -- 2.30.2