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

dje at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 21 23:26:00 GMT 2013


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



More information about the Gcc-bugs mailing list