[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cc -m486
On Mon, Mar 15, 1999 at 09:16:00PM +0900, KAMO Hiroyasu wrote:
> I know this is a bug of GCC's, not OpenBSD's.
> On OpenBSD/i386 2.4, I compiled the following C function foo().
>
> int foo(int x)
> {
> return x + 5;
> }
>
> With `cc -O2 -S foo.c', I obtained the Code 1.
> With `cc -O2 -mcpu=i486 -S foo.c', I obtained the Code 2.
>
> Code 1.
> .file "foo.c"
> gcc2_compiled.:
> ___gnu_compiled_c:
> .text
> .align 2
> .globl _foo
> .type _foo,@function
> _foo:
> pushl %ebp
> movl %esp,%ebp
> movl 8(%ebp),%eax
> addl $5,%eax
> leave
> ret
> Lfe1:
> .size _foo,Lfe1-_foo
>
> Code 2.
> .file "foo.c"
> gcc2_compiled.:
> ___gnu_compiled_c:
> .text
> .align 4
> .globl _foo
> .type _foo,@function
> _foo:
> pushl %ebp
> movl %esp,%ebp
> movl 8(%ebp),%eax
> addl $5,%eax
[extraneous instructions]
> movl %ebp,%esp
> popl %ebp
> ret
> Lfe1:
> .size _foo,Lfe1-_foo
>
> Info says that `-m486' is a synonym for `-mcpu=i486'. However, with
> `cc -O2 -m486 -S foo.c', I did not obtain Code 2 but Code 1.
>
> Is this a known bug? Is there any patch?
gcc documentation is somewhat erroneous. Actually, m486 stands for
-mcpu=i486 -march=i486, as you may check in the spec file.
That code change looks weird otherwise. I don't know much about i386, but
I believe:
* code 2 is correct
* the extraneous instructions are weird, the optimizer should remove them.
I've checked that this code generation oddity still occurs with the latest
egcs snapshot, so this is something that you should report to the
egcs bugs mailing list: egcs-bugs@egcs.cygnus.com.
--
Marc Espie
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'
- References:
- cc -m486
- From: KAMO Hiroyasu <wd@ics.nara-wu.ac.jp>
- cc -m486
- From: KAMO Hiroyasu <wd@ics.nara-wu.ac.jp>