From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5215 invoked by alias); 10 Aug 2011 00:40:46 -0000 Received: (qmail 5202 invoked by uid 22791); 10 Aug 2011 00:40:45 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from dair.pair.com (HELO dair.pair.com) (209.68.1.49) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Wed, 10 Aug 2011 00:40:32 +0000 Received: (qmail 50871 invoked by uid 20157); 10 Aug 2011 00:40:31 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 10 Aug 2011 00:40:31 -0000 Date: Wed, 10 Aug 2011 00:40:00 -0000 From: Hans-Peter Nilsson To: Richard Earnshaw cc: Richard Guenther , Mikael Pettersson , Michael Walle , Georg-Johann Lay , Richard Henderson , "gcc@gcc.gnu.org" Subject: Re: libgcc: strange optimization In-Reply-To: <4E416687.2050301@arm.com> Message-ID: References: <201108012230.29989.michael@walle.cc> <4E371AC5.5090509@redhat.com> <20023.47611.116809.875356@pilspetsen.it.uu.se> <4E37CAFB.5010401@gjlay.de> <27466ae6b9a714679fcba410cce130ba.squirrel@ssl.serverraum.org> <20023.59456.782598.31450@pilspetsen.it.uu.se> <4E416687.2050301@arm.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00200.txt.bz2 On Tue, 9 Aug 2011, Richard Earnshaw wrote: > Better still would be to change the specification and implementation of > local register variables to only guarantee them at the beginning of ASM > statements. Only for those asm statements taking the same asm-register variables as arguments. > At other times they are simply the same as other local > variables. Now we have a problem that the register allocator knows how > to solve. > > In other words, if the user writes > > bar (int y) > { > register int x asm ("r0") = y; > > foo() > > asm volatile ("mov r1, r0"); > > } > > The compiler will generate > (set (reg:SI 999 ) (reg:SI )) > (call "foo") > (set (reg:SI 0 "r0") (reg:SI 999 )) > (asm "mov r1, r0") > (set (reg:SI 999 ) (reg:SI 0 "r0")) It should rather eliminate the variable x and its assignment as it isn't used in a way properly conveyed to gcc: the occurrence of the string "r0" in the asm should not be considered. I like Ulrich Weigand's proposal better, not the least because it's how it's already documented to work. brgds, H-P