From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752286AbdIVRVb (ORCPT ); Fri, 22 Sep 2017 13:21:31 -0400 Received: from smtprelay0217.hostedemail.com ([216.40.44.217]:60865 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751877AbdIVRV3 (ORCPT ); Fri, 22 Sep 2017 13:21:29 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:2915:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3871:3872:3873:3874:4031:4250:4321:4605:5007:6119:7576:7903:9040:10004:10400:10450:10455:10848:11232:11658:11914:12043:12555:12740:12895:13069:13311:13357:13439:13894:14181:14659:14721:19904:19999:21080:21433:21627:30012:30054:30060:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: slave48_8109a7c7db263 X-Filterd-Recvd-Size: 2519 Message-ID: <1506100881.12311.41.camel@perches.com> Subject: Re: [PATCH] lib/lz4: make arrays static const, reduces object code size From: Joe Perches To: Arnd Bergmann , Colin Ian King Cc: Christophe JAILLET , Sven Schmidt <4sschmid@informatik.uni-hamburg.de>, Andrew Morton , kernel-janitors@vger.kernel.org, Linux Kernel Mailing List Date: Fri, 22 Sep 2017 10:21:21 -0700 In-Reply-To: References: <20170921221939.20820-1-colin.king@canonical.com> <5aab65d9-6da6-c770-b5aa-9edbdda31dec@wanadoo.fr> <250fe35e-77d3-a9c0-5613-ce1c65f4cb7f@canonical.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-09-22 at 09:48 +0200, Arnd Bergmann wrote: > On Fri, Sep 22, 2017 at 1:11 AM, Colin Ian King > wrote: > > On 22/09/17 00:09, Christophe JAILLET wrote: > > > Le 22/09/2017 à 00:19, Colin King a écrit : > > > > From: Colin Ian King > > > > > > > > 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}; ... }