From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 6ADBE384B0C1 for ; Fri, 4 Dec 2020 18:57:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6ADBE384B0C1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bebbosoft.de Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=s.franke@bebbosoft.de Received: from serveronline.org ([78.46.86.77]:50500 helo=bebbosoft.de) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1klGH4-0007lk-0R for gcc-help@gcc.gnu.org; Fri, 04 Dec 2020 13:57:53 -0500 Received: from ZETRA (x590fee54.dyn.telefonica.de [89.15.238.84]) by serveronline.org (BEJY V1.6.12-SNAPSHOT (c) 2000-2019 by BebboSoft, Stefan "Bebbo" Franke, all rights reserved) with SMTP id 1762f1df208ae43dbf0ee3f03f9 from s.franke@bebbosoft.de for gcc-help@gcc.gnu.org; Fri, 04 Dec 2020 19:57:40 +0100 Reply-To: From: "Stefan Franke" To: References: <32b3c0a3-9917-2b92-de59-1d6a14ecd8f8@hesbynett.no> <20201204172721.GM2672@gate.crashing.org> <20201204183317.GO2672@gate.crashing.org> <017701d6ca6d$7dc8dc90$795a95b0$@bebbosoft.de> In-Reply-To: <017701d6ca6d$7dc8dc90$795a95b0$@bebbosoft.de> Subject: AW: Correct way to express to the compiler "this does not get clobbered"? Date: Fri, 4 Dec 2020 19:57:39 +0100 Message-ID: <017801d6ca6f$56fed450$04fc7cf0$@bebbosoft.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKMzJI1tuTBQV2C9TTl/pE5jXQhpwLY7cDyATYuCFUCIfenVgIhR1yTARR7GL8CajVR2gKrXKjYArYl/0un8bD1wA== Content-Language: de Received-SPF: pass client-ip=78.46.86.77; envelope-from=s.franke@bebbosoft.de; helo=bebbosoft.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_FAIL, SPF_HELO_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2020 18:57:55 -0000 > > -----Urspr=FCngliche Nachricht----- > > Von: Gcc-help Im Auftrag von Segher > > Boessenkool > > Gesendet: Freitag, 4. Dezember 2020 19:33 > > An: Andrea Corallo > > Cc: stefan@franke.ms; gcc-help@gcc.gnu.org > > Betreff: Re: Correct way to express to the compiler "this does not = get > > clobbered"? > > > > On Fri, Dec 04, 2020 at 07:16:45PM +0100, Andrea Corallo via = Gcc-help > wrote: > > > Segher Boessenkool writes: > > > > > > > On Fri, Dec 04, 2020 at 10:52:17AM +0100, Andrea Corallo via > Gcc-help > > wrote: > > > >> stefan@franke.ms writes: > > > >> I might open a bug but my understanding is that const is > > > >> generally not used for optimizations. Am I wrong? > > > > > > > > extern const int x =3D 42; > > > > int f(void) { return x; } > > > > > > > > The code generated for f does not load the value for x from = memory: > > > > it returns 42 always. > > > > > Are you suggesting we should treat this as a bug? > > > > Huh? No, I am just saying that const *is* used for optimisation, = with > > a > dumb > > simple example. Remove const from this code and you get different > > generated machine code (that does load x from memory always). > > > > If you think you have found a missing optimisation, please make a > > self- contained demonstrator for that, and a file a PR? > > > > > > Segher IMHO it's the cprop pass which should get enhanced. Stefan