Bug 26176 - -mtune=i686 builds code including CMOV
Summary: -mtune=i686 builds code including CMOV
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.5
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-08 16:10 UTC by Stefan
Modified: 2006-02-09 21:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan 2006-02-08 16:10:29 UTC
I use a VIA Samuel 2 processor, which is a i686, but does not have the cmov capability. Therefore i used -march=i586 -mtune=i686 on my machine, because i thought mtune would tune for that architecture but leaves it compatibile to lower archs. 

But  objdump -d /usr/lib/modules/libfb.so | grep cmov shows this:
   16cb7:       0f 4c e8                cmovl  %eax,%ebp
   16cc0:       0f 4f f0                cmovg  %eax,%esi
   16ccb:       0f 4d 44 24 10          cmovge 0x10(%esp),%eax
   16ce2:       0f 4f f8                cmovg  %eax,%edi
   16eb5:       0f 45 83 e4 fd ff ff    cmovne 0xfffffde4(%ebx),%eax
   179ba:       0f 4c 74 24 28          cmovl  0x28(%esp),%esi
   179c3:       0f 4f 54 24 30          cmovg  0x30(%esp),%edx
   179d8:       0f 4c 4c 24 2c          cmovl  0x2c(%esp),%ecx
   179e1:       0f 4f 44 24 34          cmovg  0x34(%esp),%eax

So it is defenitly not downward compatible.
According to my information, this is a bug and leads to unusable binaries on my system.

My /proc/cpuinfo:
processor       : 0
vendor_id       : CentaurHauls
cpu family      : 6
model           : 7
model name      : VIA Samuel 2
stepping        : 3
cpu MHz         : 599.899
cache size      : 64 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu de tsc msr cx8 mtrr pge mmx 3dnow
bogomips        : 1183.74

i686 works fine as long as it does not contain cmov operations.
I am using gentoo and this was part of the make.cong file which produced the bug:
CFLAGS="-Os -march=i586 -mtune=i686 -mmmx -m3dnow -pipe -fomit-frame-pointer"
CHOST="i586-pc-linux-gnu"

This is my first bug here, so have merci ;) I wasn't sure which in which component this belongs, so i filed it to other. 
Is it a problem to check the cpu flags, and if they don't contain cmov, then cmov should not be used?
Comment 1 Richard Biener 2006-02-08 16:16:46 UTC
Use -v on the compilation lines of affected files and see which -march is really in effect, possibly filing a bug against Gentoo for them likely defaulting to i686.
Comment 2 Stefan 2006-02-08 17:29:57 UTC
i586-pc-linux-gnu-gcc -c -Os -march=i586 -mtune=i686 -pipe -fomit-frame-pointer -fno-strict-aliasing  -ansi -Wno-return-type -w    -I../.. -I../../exports/include   -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L                             -D_POSIX_SOURCE -D_XOPEN_SOURCE               -D_BSD_SOURCE -D_SVID_SOURCE                                 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64                                  -D_GNU_SOURCE                            -DFUNCPROTO=15 -DNARROWPROTO   -DHASXDMAUTH   Wraphelp.c

What do you want to see? Something like this?
This is part of the output while emerging/compiling xorg.

"-Os -march=i586 -mtune=i686 -pipe -fomit-frame-pointer" is part of any compile process, i can see that without the -v flag
Comment 3 Richard Biener 2006-02-09 10:06:34 UTC
> and see which -march is really in effect
^^^! so please show output of '-v' added.  If that still doesn't show i686 or up, please attach preprocessed source (-save-temps produces a Wraphelp.i for you)
Comment 4 Stefan 2006-02-09 21:08:17 UTC
I have to excuse myself, this is not a gcc bug!

I found out, that the only cmov-"infected" binaries were those of xorg.
It is a problem of mmx/sse inlcudes in their files:
https://bugs.freedesktop.org/show_bug.cgi?id=5093

So it has nothing to do with an arch/mtune setting, but with inclusion of sse!
Sorry and thanks for your patience!