public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/27800] extra temprorary created when gimplifying return
       [not found] <bug-27800-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-24  5:35 ` pinskia at gcc dot gnu.org
  2023-02-06 12:16 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-24  5:35 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |compile-time-hog,
                   |                            |memory-hog
   Last reconfirmed|2006-05-29 21:13:57         |2021-7-23
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/27800] extra temprorary created when gimplifying return
       [not found] <bug-27800-4@http.gcc.gnu.org/bugzilla/>
  2021-07-24  5:35 ` [Bug middle-end/27800] extra temprorary created when gimplifying return pinskia at gcc dot gnu.org
@ 2023-02-06 12:16 ` rguenth at gcc dot gnu.org
  2024-02-20 10:46 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-02-06 12:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Dan Nicolaescu from comment #1)
> An even simpler example which occurs quite frequently in programs:
> 
> int jjj (int a){ return bar (a); }
> 
> jjj (a)
> {
>   int D.1891;
>   int D.1892;
> 
>   D.1892 = bar (a);
>   D.1891 = D.1892;
>   return D.1891;
> }

That one is meanwhile fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/27800] extra temprorary created when gimplifying return
       [not found] <bug-27800-4@http.gcc.gnu.org/bugzilla/>
  2021-07-24  5:35 ` [Bug middle-end/27800] extra temprorary created when gimplifying return pinskia at gcc dot gnu.org
  2023-02-06 12:16 ` rguenth at gcc dot gnu.org
@ 2024-02-20 10:46 ` rguenth at gcc dot gnu.org
  2024-05-07 12:20 ` cvs-commit at gcc dot gnu.org
  2024-05-07 12:20 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-20 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note this is done on purpose, possibly to better handle functions with multiple
returns.

A fix is probably in gimplification of the MODIFY_EXPR

  D.2774 = a != 0 ? b : c

where gimplify_cond_expr isn't told it can re-use the LHS as temporary.
That means special-casing this COND_EXPR RHS in gimplify_modify_expr_rhs
which already handles the non-register type case.  It could be extended
to cover all cases which then generates the smaller

int iii (int a, int b, int c)
{
  int D.2774;

  if (a != 0) goto <D.2775>; else goto <D.2776>;
  <D.2775>:
  D.2774 = b;
  goto <D.2777>;
  <D.2776>:
  D.2774 = c;
  <D.2777>:
  return D.2774;
}

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 76221f7637d..b48c43f1471 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -5985,7 +5985,7 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p,
tree *to_p,
             down into the branches.  This is mandatory for ADDRESSABLE types,
             since we cannot generate temporaries for such, but it saves a
             copy in other cases as well.  */
-         if (!is_gimple_reg_type (TREE_TYPE (*from_p)))
+         if (1)
            {
              /* This code should mirror the code in gimplify_cond_expr. */
              enum tree_code code = TREE_CODE (*expr_p);

or to cases where is_gimple_reg (*to_p).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/27800] extra temprorary created when gimplifying return
       [not found] <bug-27800-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2024-02-20 10:46 ` rguenth at gcc dot gnu.org
@ 2024-05-07 12:20 ` cvs-commit at gcc dot gnu.org
  2024-05-07 12:20 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-07 12:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:bed6ec161be8c5ca2f24195900ce3c9b81c3e141

commit r15-276-gbed6ec161be8c5ca2f24195900ce3c9b81c3e141
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Feb 20 11:47:03 2024 +0100

    middle-end/27800 - avoid unnecessary temporary during gimplification

    This avoids a tempoary when gimplifying reg = a ? b : c, re-using
    the LHS of an assignment if that's a register.

            PR middle-end/27800
            * gimplify.cc (gimplify_modify_expr_rhs): For a COND_EXPR
            avoid a temporary from gimplify_cond_expr when the LHS is
            a register by pushing the assignment into the COND_EXPR arms.

            * gcc.dg/pr27800.c: New testcase.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/27800] extra temprorary created when gimplifying return
       [not found] <bug-27800-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2024-05-07 12:20 ` cvs-commit at gcc dot gnu.org
@ 2024-05-07 12:20 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07 12:20 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
I consider this fixed as far as possible now.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-07 12:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-27800-4@http.gcc.gnu.org/bugzilla/>
2021-07-24  5:35 ` [Bug middle-end/27800] extra temprorary created when gimplifying return pinskia at gcc dot gnu.org
2023-02-06 12:16 ` rguenth at gcc dot gnu.org
2024-02-20 10:46 ` rguenth at gcc dot gnu.org
2024-05-07 12:20 ` cvs-commit at gcc dot gnu.org
2024-05-07 12:20 ` rguenth at gcc dot gnu.org

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).