public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Simon Kagstrom <simon.kagstrom@bth.se>
To: gcc-help@gcc.gnu.org
Subject: -fno-delayed-branch and the bne-instruction on MIPS
Date: Fri, 07 Jul 2006 06:17:00 -0000	[thread overview]
Message-ID: <87d5cihrbz.wl%simon.kagstrom@bth.se> (raw)

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 <game_loop>
     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 <game_init+0x7c>
     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

             reply	other threads:[~2006-07-07  6:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-07  6:17 Simon Kagstrom [this message]
2006-07-07 17:33 ` Ian Lance Taylor
2006-07-10  6:53   ` Simon Kagstrom
2006-07-10 16:27     ` Ian Lance Taylor
2006-07-11  6:57       ` Simon Kagstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d5cihrbz.wl%simon.kagstrom@bth.se \
    --to=simon.kagstrom@bth.se \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).