From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11255 invoked by alias); 7 Jul 2006 06:17:13 -0000 Received: (qmail 11226 invoked by uid 22791); 7 Jul 2006 06:17:11 -0000 X-Spam-Check-By: sourceware.org Received: from stafffront2.bth.se (HELO stafffront2.bth.se) (194.47.129.29) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Jul 2006 06:17:08 +0000 Received: by stafffront2.bth.se (Postfix, from userid 102) id 29854630086; Fri, 7 Jul 2006 08:17:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by stafffront2.bth.se (Postfix) with ESMTP id D54C2630081 for ; Fri, 7 Jul 2006 08:16:59 +0200 (CEST) Received: from stafffront2.bth.se ([127.0.0.1]) by localhost (stafffront2 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32123-01 for ; Fri, 7 Jul 2006 08:16:59 +0200 (CEST) Received: from lska.ipd.bth.se (ipdska.ipd.bth.se [194.47.135.165]) by stafffront2.bth.se (Postfix) with ESMTP id 8BCAF630080 for ; Fri, 7 Jul 2006 08:16:59 +0200 (CEST) Date: Fri, 07 Jul 2006 06:17:00 -0000 Message-ID: <87d5cihrbz.wl%simon.kagstrom@bth.se> From: Simon Kagstrom To: gcc-help@gcc.gnu.org Subject: -fno-delayed-branch and the bne-instruction on MIPS User-Agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/21.4 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII 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/msg00062.txt.bz2 Hello! I'm working on a binary translator that translates MIPS binaries into Java bytecode (http://spel.bth.se/index.php/Cibyl) with the goal of "recompiling" C programs to run on J2ME. To simplify things, I use compile programs for a subset of the MIPS1 instruction set, and ideally I would like to get rid of delayed instructions. 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? // Simon