[PATCH] Re: Canonical type nodes, or, comptypes considered harmful

Doug Gregor doug.gregor@gmail.com
Tue Nov 21 19:09:00 GMT 2006


On 11/21/06, Benjamin Kosnik <bkoz@redhat.com> wrote:
> I would like to test some compile-time issues myself, but am having
> trouble appying this patch. Was it generated off of mainline? Any
> chance it could be re-generated off of r118977 or later?

I've re-generated the patch against today's Subversion revision. The
new patch is attached, along with some more performance numbers... 85%
speedup, anyone?

> 'make check-compile'

About 4.5% speedup here.

> edit out libstdc++-v3/scripts/check_performance
>
> to only compile, ie
>
> - FLAGS=`$flags_script --cxxflags`
> + FLAGS="-g -O2 -S"

About 3% here.

I think the fact that we're using precompiled headers for most of the
libstdc++ testing means that we're not spending as much time in
parsing templates as we'd expect.

Of course, if you want to see speedup from canonical types... I played
around with Todd Veldhuizen's little compiler killer (shown at the end
of this message). At DEPTH=5, we get a 59% speedup:

  "Pure" GCC, without my patch: 0m2.555s
  Using canonical types: 0m1.603s

Make DEPTH=6, we get an 85% speedup:

  "Pure" GCC, without my patch: 3m0.383s
  Using canonical types: 1m37.256s

So, big performance gains are definitely possible, and I really
haven't seen any slowdown associated with this patch.

  Cheers,
  Doug

    /* BEGIN_DEATH */
    template<int Depth, int A, typename B>
    struct K17 {
      static const int x =
        K17<Depth+1, 0, K17<Depth,A,B> >::x
      + K17<Depth+1, 1, K17<Depth,A,B> >::x
      + K17<Depth+1, 2, K17<Depth,A,B> >::x
      + K17<Depth+1, 3, K17<Depth,A,B> >::x
      + K17<Depth+1, 4, K17<Depth,A,B> >::x;
    };

    template<int A, typename B>
    struct K17<DEPTH,A,B> {
      static const int x = 1;
    };

    static const int z = K17<0,0,int>::x;
    /* END_DEATH */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: canonical-types.patch
Type: text/x-patch
Size: 30367 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061121/ba86e488/attachment.bin>


More information about the Gcc-patches mailing list