Re: [RFC PATCH] pre-process: add __VA_OPT__ support
Linus Torvalds <[email protected]> Wed, 18 Mar 2026 21:07:17 -0700
| Newsgroups | org.kernel.vger.linux-sparse |
|---|---|
| Message-ID | <CAHk-=wh7zNVQ0k1o_3cgGiCdcpYFCvbZ2O3ZLQW-q2xXqusmww@mail.gmail.com> |
On Wed, 18 Mar 2026 at 20:50, Al Viro <[email protected]> wrote: > > Speaking of rants: gcc code generation in general and around bitfields. Yeah. gcc handling of bitfields is a disaster. I made a gcc bugzilla about some of this many years ago (almost exactly 15 years ago): https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48696 and things haven't really improved much since, afaik. I suggested at the time that gcc should stop doing bitfields internally, and translate it all into shifts and masks and then doing all the normal optimizations on those. But that's not what it does - gcc keeps it as a "bitfield access" way too long in the optimization phases, and then does a really bad job of optimizing it all. And yes, I made that bugzilla entry due to sparse, and that 'struct pos'. Because it really triggers all kinds of horrendous gcc behavior. I looked at clang at one point, and iirc it generated *much* better code, because I think it does tth esmart thing, which is to get rid of the notion of bitfields as quickly as possible, and then doing just regular integer optimizations. (And the real problem with gcc is really that "byte write followed by word read", which is horribly horribly expensive because it causes a pipeline stall. So even when the code looks small, it's really really bad. Clang actually generates more instructions for the test-case in that bugzilla, but the code is ten times faster because it doesn't stall the pipeline) Linus