public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/51982] New: Shrink-wrapping opportunity
@ 2012-01-24 19:08 dje at gcc dot gnu.org
  2012-01-24 19:42 ` [Bug middle-end/51982] " dje at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dje at gcc dot gnu.org @ 2012-01-24 19:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51982

             Bug #: 51982
           Summary: Shrink-wrapping opportunity
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dje@gcc.gnu.org


Created attachment 26444
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26444
lookdict_string manually split equivalent to shrink-wrapping

I realize that the shrink-wrapping implementation in GCC is preliminary and
conservative. I tested it on an example that presents a good opportunity for
shrink-wrapping and a large perforamnce improvement, but the current
implementation was not able to apply the optimization.

The attached file manually splits the CPython lookdict_string() into two
functions where most of the prologue can be avoided on the slow path.


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

* [Bug middle-end/51982] Shrink-wrapping opportunity
  2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
  2012-01-24 19:42 ` [Bug middle-end/51982] " dje at gcc dot gnu.org
@ 2012-01-24 19:42 ` pinskia at gcc dot gnu.org
  2012-02-06  7:07 ` amodra at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-24 19:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51982

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |10474

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-24 19:02:33 UTC ---
This is most likely the same reference problem as in PR 10474 comment #10.


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

* [Bug middle-end/51982] Shrink-wrapping opportunity
  2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
@ 2012-01-24 19:42 ` dje at gcc dot gnu.org
  2012-01-24 19:42 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dje at gcc dot gnu.org @ 2012-01-24 19:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51982

David Edelsohn <dje at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-24
                 CC|                            |amodra at gcc dot gnu.org
     Ever Confirmed|0                           |1


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

* [Bug middle-end/51982] Shrink-wrapping opportunity
  2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
  2012-01-24 19:42 ` [Bug middle-end/51982] " dje at gcc dot gnu.org
  2012-01-24 19:42 ` pinskia at gcc dot gnu.org
@ 2012-02-06  7:07 ` amodra at gmail dot com
  2013-04-21 23:26 ` dje at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: amodra at gmail dot com @ 2012-02-06  7:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51982

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|amodra at gcc dot gnu.org   |amodra at gmail dot com

--- Comment #2 from Alan Modra <amodra at gmail dot com> 2012-02-06 07:07:41 UTC ---
I confirm comment #2.  We do have incoming args being saved in callee-saved
regs and those callee-saved regs then being used.

However, there are additional problems to solve before this function will ever
be shrink-wrapped.  We have uses of callee-saved regs for more than just
incoming args.  For instance, "mask" gets put in r24 and "ep0" in r25 in the
first bb, and a little later, "i" in r29 and others are used for other
intermediate values.


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

* [Bug middle-end/51982] Shrink-wrapping opportunity
  2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-02-06  7:07 ` amodra at gmail dot com
@ 2013-04-21 23:26 ` dje at gcc dot gnu.org
  2013-11-25 13:10 ` jamborm at gcc dot gnu.org
  2021-12-25 11:32 ` [Bug rtl-optimization/51982] " pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dje at gcc dot gnu.org @ 2013-04-21 23:26 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51982

--- Comment #3 from David Edelsohn <dje at gcc dot gnu.org> 2013-04-21 23:26:03 UTC ---
Created attachment 29912
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29912
self-contained example

The function lookup_unicode should be shrink-wrapped to not create a stack
frame if unicode_eq is not called, which is the common case

    if (!PyUnicode_CheckExact(key)) {
        return lookdict(mp, key, hash, value_addr);
    }
    i = (size_t)hash & mask;
    ep = &ep0[i];
    if (ep->me_key == NULL || ep->me_key == key) {
        *value_addr = &ep->me_value;
        return ep;
    }
/* ----- Postpone frame creation until this point. ------ */
    if (ep->me_key == dummy)
        freeslot = ep;
    else {
        if (ep->me_hash == hash && unicode_eq(ep->me_key, key)) {
            *value_addr = &ep->me_value;
            return ep;
        }
        freeslot = NULL;
    }


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

* [Bug middle-end/51982] Shrink-wrapping opportunity
  2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-04-21 23:26 ` dje at gcc dot gnu.org
@ 2013-11-25 13:10 ` jamborm at gcc dot gnu.org
  2021-12-25 11:32 ` [Bug rtl-optimization/51982] " pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jamborm at gcc dot gnu.org @ 2013-11-25 13:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51982

Bug 51982 depends on bug 10474, which changed state.

Bug 10474 Summary: shrink wrapping for functions
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10474

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED


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

* [Bug rtl-optimization/51982] Shrink-wrapping opportunity
  2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-11-25 13:10 ` jamborm at gcc dot gnu.org
@ 2021-12-25 11:32 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-25 11:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2012-01-24 00:00:00         |2021-12-25
          Component|middle-end                  |rtl-optimization

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note in the self-contained example, you need to remove the static from
lookdict_unicode function.

But I still see there is no shrink-wrapping happening on aarch64, even though
it could with some minor register allocation changes.

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

end of thread, other threads:[~2021-12-25 11:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 19:08 [Bug middle-end/51982] New: Shrink-wrapping opportunity dje at gcc dot gnu.org
2012-01-24 19:42 ` [Bug middle-end/51982] " dje at gcc dot gnu.org
2012-01-24 19:42 ` pinskia at gcc dot gnu.org
2012-02-06  7:07 ` amodra at gmail dot com
2013-04-21 23:26 ` dje at gcc dot gnu.org
2013-11-25 13:10 ` jamborm at gcc dot gnu.org
2021-12-25 11:32 ` [Bug rtl-optimization/51982] " pinskia 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).