Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time

From: Sedat Dilek
Date: Wed May 27 2020 - 07:36:51 EST


On Wed, May 27, 2020 at 1:27 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> On Wed, May 27, 2020 at 12:33 PM Marco Elver <elver@xxxxxxxxxx> wrote:
> >
> > If the compiler supports C11's _Generic, use it to speed up compilation
> > times of __unqual_scalar_typeof(). GCC version 4.9 or later and
> > all supported versions of Clang support the feature (the oldest
> > supported compiler that doesn't support _Generic is GCC 4.8, for which
> > we use the slower alternative).
> >
> > The non-_Generic variant relies on multiple expansions of
> > __pick_integer_type -> __pick_scalar_type -> __builtin_choose_expr,
> > which increases pre-processed code size, and can cause compile times to
> > increase in files with numerous expansions of READ_ONCE(), or other
> > users of __unqual_scalar_typeof().
> >
> > Summary of compile-time benchmarking done by Arnd Bergmann [1]:
> >
> > <baseline normalized time> clang-11 gcc-9
> > this patch 0.78 0.91
> > ideal 0.76 0.86
> >
> > [1] https://lkml.kernel.org/r/CAK8P3a3UYQeXhiufUevz=rwe09WM_vSTCd9W+KvJHJcOeQyWVA@xxxxxxxxxxxxxx
> >
> > Further compile-testing done with:
> > gcc 4.8, 4.9, 5.5, 6.4, 7.5, 8.4;
> > clang 9, 10.
> >
> > Reported-by: Arnd Bergmann <arnd@xxxxxxxx>
> > Signed-off-by: Marco Elver <elver@xxxxxxxxxx>
>
> This gives us back 80% of the performance drop on clang, and 50%
> of the drop I saw with gcc, compared to current mainline.
>
> Tested-by: Arnd Bergmann <arnd@xxxxxxxx>
>

Hi Arnd,

with "mainline" you mean Linux-next aka Linux v5.8 - not v5.7?
I have not seen __unqual_scalar_typeof(x) in compiler_types.h in Linux v5.7.

Is there a speedup benefit also for Linux v5.7?
Which patches do I need?

Thanks.

Regards,
- Sedat -