public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Simon Kagstrom <simon.kagstrom@bth.se>
Cc: gcc-help@gcc.gnu.org
Subject: Re: -fno-delayed-branch and the bne-instruction on MIPS
Date: Mon, 10 Jul 2006 16:27:00 -0000	[thread overview]
Message-ID: <m38xn1xw60.fsf@localhost.localdomain> (raw)
In-Reply-To: <877j2mhrxu.wl%simon.kagstrom@bth.se>

Simon Kagstrom <simon.kagstrom@bth.se> writes:

> Unfortunately there was no difference with -Wa,-O0. It does however
> look like the use of Linux-style syscalls break the
> -fno-delayed-branch behavior. I have code like
> 
>    #define _syscall1(type,name,atype,a) \
>    type name(atype a) \
>    { \
> 	   register unsigned long __a0 asm("$4") = (unsigned long) a; \
> 	   register unsigned long __v0 asm("$2"); \
> 	   \
> 	   __asm__ volatile ( \
> 	   ".set\tnoreorder\n\t" \
> 	   "li\t$2, %2\t\t\t# " #name "\n\t" \
> 	   "syscall\n\t" \
> 	   ".set\treorder" \
> 	   : "=&r" (__v0) \
> 	   : "r" (__a0), "i" (__NR_##name) \
> 	   ); \
> 	   \
> 	   return (type) __v0; \
>    }
>    #define __NR_exit 0
>    static inline _syscall1(void,exit , int, code );
> 
> and with the call of exit(...), the delay slots are filled with
> instructions. If I just define a plain function and call that,
> -fno-delayed-branch seems to behave correctly.

I see.  This is not a bug in the compiler.  The ".set reorder"
directive tells the assembler that it should reorder instructions into
branch delay slots when possible.  The compiler just copies the ".set
reorder" directly from the asm statement.  Both the compiler and the
assembler are acting as expected.

You should rewrite your asm statement to not use .set reorder.  Do this instead:
    .set push
    .set noreorder
    ...
    .set pop


> Anyway, I've submitted a bug report at
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28325

I've closed out this bug report.

Ian

  reply	other threads:[~2006-07-10 16:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-07  6:17 Simon Kagstrom
2006-07-07 17:33 ` Ian Lance Taylor
2006-07-10  6:53   ` Simon Kagstrom
2006-07-10 16:27     ` Ian Lance Taylor [this message]
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=m38xn1xw60.fsf@localhost.localdomain \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=simon.kagstrom@bth.se \
    /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).