[Bug middle-end/51982] Shrink-wrapping opportunity

bergner at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 21 17:38:00 GMT 2018


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

--- Comment #4 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to David Edelsohn from comment #3)
> 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'm guessing lookdict() above is inlined so not a call...


>     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;
>     }

For us to postpone frame creation to the point you specify above, we'd need to
split all of the pseudos that are live at that point and who are live across a
call (ie, pseudos that IRA will attempt to assign to a
non-volatile/callee-saved register).  That would allow IRA to use a volatile
reg for the split pseudo above the frame setup point and a non-volatile reg for
the split pseudo after the frame setup point.
Of course we'd need to inhibit coalescing the copy away.

Doesn't IRA have code that tries to do such a thing?  /me goes off to have a
look.


More information about the Gcc-bugs mailing list