-fno-delayed-branch and the bne-instruction on MIPS
Simon Kagstrom
simon.kagstrom@bth.se
Mon Jul 10 06:53:00 GMT 2006
At 07 Jul 2006 10:32:28 -0700,
Ian Lance Taylor wrote:
>
> Simon Kagstrom <simon.kagstrom@bth.se> writes:
>
> > So, I used the -fno-delayed-branch instruction when compiling, which
> > is documented as
> > [...]
>
> 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.
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.
Anyway, I've submitted a bug report at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28325
Thanks for the input!
// Simon
More information about the Gcc-help
mailing list