public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50495] New: Optimize exact matches in overload resolution
@ 2011-09-23 14:55 mathias at gaunard dot com
  2011-09-23 15:07 ` [Bug c++/50495] " paolo.carlini at oracle dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: mathias at gaunard dot com @ 2011-09-23 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50495
           Summary: Optimize exact matches in overload resolution
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mathias@gaunard.com


Overload resolution in GCC (and in C++ in general) is quite slow, and I would
like to suggest the following enhancement: look-up (in constant or logarithmic
time) for exact matches first, then perform regular overload resolution if
necessary.

The idea is that

    struct id_0 {};
    void f(id_0);

    struct id_1;
    void f(id_1) {};

    ...

and then calling

    f(id_x());

should be as fast as

    void f_0();
    void f_1();
    ...

and then calling

    f_x();

Now if this could be made to work for things like

    struct h0 {};
    struct h1 : h0 {};

    struct id_0 {};
    template<class T> void f(id_0, h0<T>);
    template<class T> void f(id_0, h1<T>);

to reduce the set of possible overloads to 2 early (templates inserted to make
it non-absolutely orderable), that would be perfect.

According to my benchmarks, resolving a function with an exact match on the
first argument among 1,000 tags with 10 overloads each takes 30s, while with
1,000 differently named functions of 10 overloads each it takes 100ms.


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

end of thread, other threads:[~2011-09-24 22:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-23 14:55 [Bug c++/50495] New: Optimize exact matches in overload resolution mathias at gaunard dot com
2011-09-23 15:07 ` [Bug c++/50495] " paolo.carlini at oracle dot com
2011-09-23 15:53 ` mathias at gaunard dot com
2011-09-23 16:05 ` jason at gcc dot gnu.org
2011-09-23 16:20 ` jason at gcc dot gnu.org
2011-09-23 17:07 ` mathias at gaunard dot com
2011-09-23 17:19 ` paolo.carlini at oracle dot com
2011-09-23 19:02 ` mathias at gaunard dot com
2011-09-23 19:14 ` mathias at gaunard dot com
2011-09-24 22:55 ` paolo.carlini at oracle dot com

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