From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16885 invoked from network); 23 May 2023 22:21:10 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 23 May 2023 22:21:10 -0000 Received: (qmail 13705 invoked by uid 550); 23 May 2023 22:21:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 13637 invoked from network); 23 May 2023 22:21:06 -0000 Date: Wed, 24 May 2023 00:20:54 +0200 From: Szabolcs Nagy To: Rich Felker Cc: musl@lists.openwall.com Message-ID: <20230523222054.GY3630668@port70.net> Mail-Followup-To: Rich Felker , musl@lists.openwall.com References: <20230522164841.GS4163@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230522164841.GS4163@brightrain.aerifal.cx> Subject: Re: [musl] Dropping -Os * Rich Felker [2023-05-22 12:48:42 -0400]: > It's been known for a long time now that -Os is bad, mainly because it > imposes a few really ugly pessimizations without their own switches, > like forcing use of div instructions for div-by-constant instead of > allowing strength reduction to a mul (because the mul takes a couple > more bytes of .text O_o). > > The attached proposed change switches over to starting with -O2 and > patching it up with the actually-desirable parts of -Os. > > AIUI, at least with GCC this has other side effects, because the -O3 > used with OPTIMIZE_GLOBS (--enable-optimize for particular components) > will not override explicit -f options. So there might be more work > that should be done splitting out the size/speed CFLAGS into separate > variables and only applying one to each file, rather than putting -O3 > on top like we do now. Or it might not matter. > > It's also perhaps worth considering whether this breakdown still makes > sense, or if there are unified options that would have low size cost > but achieve the bulk of the benefit of -O3. sounds good. on aarch64 with gcc12 -Os vs -O2+-f* is 4% size increase and -Os vs -O2 is 10% size increase (libc.so). the 4% seems to be mostly inlining decisions (including inlining small memset/memcpy). the -f does change -O3 code gen, but i cant tell by just looking at the asm how much that matters.