public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/115097] Strange suboptimal codegen specifically at -O2 when copying struct type
Date: Wed, 15 May 2024 07:34:17 +0000	[thread overview]
Message-ID: <bug-115097-4-N7J2jWFYQN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-115097-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115097

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
[...]
>   /* If aggregate_value_p is true, then we can return the bare RESULT_DECL.
>      Recall that aggregate_value_p is FALSE for any aggregate type that is
>      returned in registers.  If we're returning values in registers, then
>      we don't want to extend the lifetime of the RESULT_DECL, particularly
>      across another call.  In addition, for those aggregates for which
>      hard_function_value generates a PARALLEL, we'll die during normal
>      expansion of structure assignments; there's special code in
> expand_return
>      to handle this case that does not exist in expand_expr.  */
> 
> but the code does something else, using a new temporary register
> (here !aggregate_value_p).  The following fixes that.
> 
> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
> index b0ed58ed0f9..e4cf5438e39 100644
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -1873,7 +1873,8 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p)
>       to handle this case that does not exist in expand_expr.  */
>    if (!result_decl)
>      result = NULL_TREE;
> -  else if (aggregate_value_p (result_decl, TREE_TYPE
> (current_function_decl)))
> +  else if (aggregate_value_p (result_decl, TREE_TYPE
> (current_function_decl))
> +          || !is_gimple_reg_type (TREE_TYPE (result_decl)))
>      {
>        if (!poly_int_tree_p (DECL_SIZE (result_decl)))
>         {

That said, this likely breaks exactly what the comment says but this should
be then worked around during RTL expansion and not gimplification (but
of course historically that was the same time).

  parent reply	other threads:[~2024-05-15  7:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15  1:02 [Bug c/115097] New: " arthur.j.odwyer at gmail dot com
2024-05-15  6:50 ` [Bug tree-optimization/115097] " rguenth at gcc dot gnu.org
2024-05-15  7:05 ` [Bug ipa/115097] " rguenth at gcc dot gnu.org
2024-05-15  7:10 ` jakub at gcc dot gnu.org
2024-05-15  7:12 ` pinskia at gcc dot gnu.org
2024-05-15  7:24 ` rguenth at gcc dot gnu.org
2024-05-15  7:34 ` rguenth at gcc dot gnu.org [this message]
2024-05-15  9:05 ` hubicka at ucw dot cz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-115097-4-N7J2jWFYQN@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).