From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14221 invoked by alias); 13 Oct 2011 11:38:21 -0000 Received: (qmail 14165 invoked by uid 22791); 13 Oct 2011 11:38:20 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Oct 2011 11:38:02 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9DBc1Bj001344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 13 Oct 2011 07:38:02 -0400 Received: from zebedee.pink (ovpn-113-55.phx2.redhat.com [10.3.113.55]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9DBc03F031152; Thu, 13 Oct 2011 07:38:01 -0400 Message-ID: <4E96CD98.5070704@redhat.com> Date: Thu, 13 Oct 2011 11:38:00 -0000 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Thunderbird/3.1.15 MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Re: gcc optimises out test of value in register-only loop References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00088.txt.bz2 On 10/13/2011 12:23 PM, MikeW wrote: > sh4-linux-gcc (GCC) 4.2.4 [unfortunately the version is tied to the > kernel build. ] > > In some kernel code where RAM is unavailable due to manipulation of the MMU, > I wanted to place some 'got here' stops in the code so I could ^C break in gdb, > reset a register value and allow execution to continue. > > Accordingly I tried: > volatile register int stop_loop __asm("r5")__; > ... > stop_loop = 0x1234; > (disable MMU) > while (stop_loop != 0); > ... > > which seemed to generate code that checks the value of r5 only once: > > xxxx08: mov r5,r1 > xxxx0a: tst r1,r1 > xxxx0c: bf xxxx0c ;r5 never tested again!! > xxxx0e: (unrelated code) > > I also tried > while ((volatile)stop_loop != 0); > and > while ((volatile)(stop_loop != 0)); > > which both gave the original asm code as above. > > So, in short, is there any way to persuade gcc to reload r5 - which could > in other non-debug situations be a global register variable updated > in an ISR, for example. I don't think so. If every there was a case for "use asm", it's surely this. Andrew.