From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17005 invoked by alias); 7 Jul 2006 17:33:49 -0000 Received: (qmail 16997 invoked by uid 22791); 7 Jul 2006 17:33:48 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.12) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Jul 2006 17:33:46 +0000 Received: from lois.corp.google.com (lois.corp.google.com [172.24.0.50]) by smtp-out.google.com with ESMTP id k67HWlxQ002806; Fri, 7 Jul 2006 10:32:52 -0700 Received: from dhcp-172-18-108-229.corp.google.com.google.com (dhcp-172-18-108-229.corp.google.com [172.18.108.229]) (authenticated bits=0) by lois.corp.google.com with ESMTP id k67HWStb013986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 7 Jul 2006 10:32:29 -0700 To: Simon Kagstrom Cc: gcc-help@gcc.gnu.org Subject: Re: -fno-delayed-branch and the bne-instruction on MIPS References: <87d5cihrbz.wl%simon.kagstrom@bth.se> From: Ian Lance Taylor Date: Fri, 07 Jul 2006 17:33:00 -0000 In-Reply-To: <87d5cihrbz.wl%simon.kagstrom@bth.se> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-07/txt/msg00071.txt.bz2 Simon Kagstrom writes: > So, I used the -fno-delayed-branch instruction when compiling, which > is documented as > > If supported for the target machine, attempt to reorder > instructions to exploit instruction slots available after delayed > branch instructions. > > I use GCC 3.4.4 from the emdebian project, > > mips-linux-gcc (GCC) 3.4.4 20050314 (prerelease) (Debian 3.4.3-13) > > -fno-delayed-branch seems to mostly work, i.e., I get code as > > 10001d0: 27a40010 addiu a0,sp,16 > 10001d4: 0c400008 jal 1000020 > 10001d8: 00000000 nop > > which is what I want. However, on conditional branches, it doesn't > work as expected: > > 1000160: 8c670000 lw a3,0(v1) > 1000164: 24020013 li v0,19 > 1000168: 0000000c syscall > 100016c: 25080001 addiu t0,t0,1 > 1000170: 29020018 slti v0,t0,24 > 1000174: 1440fff9 bnez v0,100015c > 1000178: 24630060 addiu v1,v1,96 > > Here, I would have expected that the addiu would go before bnez, and > that a nop is inserted after the branch. > > > So the question is if this is the intended behavior, or if it simply > is a bug with the -fno-delayed-branch implementation? This looks like a bug to me. You may want to open a bug report; see http://gcc.gnu.org/bugs.html I suspect the bug is that -fdelayed-branch is failing to pass -O0 to the assembler. Try compiling with -Wa,-O0. Ian