From: Joe Perches <joe@perches.com>
To: Arnd Bergmann <arnd@arndb.de>, Colin Ian King <colin.king@canonical.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Sven Schmidt <4sschmid@informatik.uni-hamburg.de>,
Andrew Morton <akpm@linux-foundation.org>,
kernel-janitors@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] lib/lz4: make arrays static const, reduces object code size
Date: Fri, 22 Sep 2017 17:21:21 +0000 [thread overview]
Message-ID: <1506100881.12311.41.camel@perches.com> (raw)
In-Reply-To: <CAK8P3a1ryR2oXnqrMt+L0_v1G+NggvejX+L31V=QtCBt1cfZWg@mail.gmail.com>
On Fri, 2017-09-22 at 09:48 +0200, Arnd Bergmann wrote:
> On Fri, Sep 22, 2017 at 1:11 AM, Colin Ian King
> <colin.king@canonical.com> wrote:
> > On 22/09/17 00:09, Christophe JAILLET wrote:
> > > Le 22/09/2017 à 00:19, Colin King a écrit :
> > > > From: Colin Ian King <colin.king@canonical.com>
> > > >
> > > > Don't populate the read-only arrays dec32table and dec64table on the
> > > > stack, instead make them both static const. Makes the object code
> > > > smaller by over 10K bytes:
> > >
> > > 10k? Wouaouh! This is way much more than what you usually win with such
> > > patches.
> >
> > Yes, I had to triple check it because it was an unbelievable win.
> >
>
> I wonder whether this should be reported as a gcc bug. I tried reproducing
> it here with gcc-7.1.1 and gcc-8.0.0, but I only see a 4K difference:
>
> text data bss dec hex filename
> 18220 176 0 18396 47dc build/tmp/lib/lz4/lz4_decompress-after.o
> 22297 0 0 22297 5719 build/tmp/lib/lz4/lz4_decompress-before.o
Perhaps not so much a gcc bug as an opportunity
for gcc to add an additional optimization.
gcc would have to verify that the const array is
not initialized with some variable or argument like:
int foo(int a)
{
const int array[] = {1, a};
...
}
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-09-22 17:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 22:19 [PATCH] lib/lz4: make arrays static const, reduces object code size Colin King
2017-09-21 23:09 ` Christophe JAILLET
2017-09-21 23:11 ` Colin Ian King
2017-09-22 7:48 ` Arnd Bergmann
2017-09-22 17:21 ` Joe Perches [this message]
2017-09-22 19:17 ` Arnd Bergmann
2017-09-22 19:38 ` Arnd Bergmann
2017-09-22 21:39 ` Arnd Bergmann
2017-09-22 21:43 ` Colin Ian King
2017-09-23 1:33 ` Joe Perches
2017-09-23 1:33 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1506100881.12311.41.camel@perches.com \
--to=joe@perches.com \
--cc=4sschmid@informatik.uni-hamburg.de \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=christophe.jaillet@wanadoo.fr \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox