User account creation filtered due to spam.

Bug 49128 - -march=native generates unsupported instructions
Summary: -march=native generates unsupported instructions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.0
: P3 critical
Target Milestone: 4.6.1
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-23 16:18 UTC by natchouf
Modified: 2011-05-25 13:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-25 06:23:13


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description natchouf 2011-05-23 16:18:11 UTC
With gcc (GCC) 4.6.0 20110513 (prerelease)
I compile on my laptop : 
----
Intel(R) Pentium(R) CPU        U5400  @ 1.20GHz
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm 
pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl e
st tm2 ssse3 cx16 xtpr pdcm popcnt lahf_lm arat dts
----

then "gcc -mtune=native" generates unsuported instructions like PINSRD (which is part of SSE4.1 according to wikipedia, not supported by this CPU)
I guess -mtune=native uncorrectly detects this CPU in version 4.6.0
Version 4.5.x did work correctly.

WORKAROUND: use -mtune=core2
Comment 1 Jonathan Wakely 2011-05-23 16:53:00 UTC
you haven't provided the necessary information requested at http://gcc.gnu.org/bugs/

Specifically you need to say how your gcc was configured (because -mtune should not affect the instructions gcc thinks are supported, that's set by -march) and provide your full compilation command and example code which reproduces the problem
Comment 2 H.J. Lu 2011-05-23 18:11:35 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01664.html
Comment 3 natchouf 2011-05-23 20:32:14 UTC
Oups, I'm sorry. -mtune should be replaced by -march everywhere in my report...

Thanks for the patch.
Comment 4 natchouf 2011-05-23 20:36:15 UTC
(In reply to comment #2)
> A patch is posted at
> 
> http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01664.html

in the patch you linked to, I think there is a mistake in these lines :

+      const char *sse4_2 = has_sse4_2 ? " -msse4.2" : " -msse4.2";
+      const char *sse4_1 = has_sse4_1 ? " -msse4.1" : " -msse4.1";
Comment 5 hjl@gcc.gnu.org 2011-05-24 17:38:38 UTC
Author: hjl
Date: Tue May 24 17:38:34 2011
New Revision: 174126

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174126
Log:
Always add -mno-XXX for -march=native.

2011-05-24  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/49128
	* config/i386/driver-i386.c (host_detect_local_cpu): Always
	add -mno-XXX.  Handle FMA.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/driver-i386.c
Comment 6 hjl@gcc.gnu.org 2011-05-24 17:41:54 UTC
Author: hjl
Date: Tue May 24 17:41:51 2011
New Revision: 174127

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174127
Log:
Always add -mno-XXX for -march=native.

2011-05-24  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline
	2011-05-24  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/49128
	* config/i386/driver-i386.c (host_detect_local_cpu): Always
	add -mno-XXX.  Handle FMA.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/driver-i386.c
Comment 7 H.J. Lu 2011-05-24 17:55:21 UTC
Fixed.
Comment 8 Joost VandeVondele 2011-05-25 06:23:13 UTC
This patch causes for me:

> gfortran-trunk -march=native test.f90
f951: error: unrecognized command line option ‘-mno-msse4.2’

in full:

> gfortran-trunk -v -march=native test.f90
Driving: gfortran-trunk -v -march=native test.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran-trunk
COLLECT_LTO_WRAPPER=/data/vondele/gcc_bench/gcc_trunk/build/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /data/vondele/gcc_bench/gcc_trunk/gcc/configure --prefix=/data/vondele/gcc_bench/gcc_trunk/build --enable-languages=c,c++,fortran --program-suffix=-trunk --disable-multilib --disable-bootstrap --with-gmp=/data/vondele/gcc_bench/libs/ --with-mpfr=/data/vondele/gcc_bench/libs/ --with-mpc=/data/vondele/gcc_bench/libs/
Thread model: posix
gcc version 4.7.0 20110524 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-march=native' '-shared-libgcc'
 /data/vondele/gcc_bench/gcc_trunk/build/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/f951 test.f90 -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-msse4.2 -mno-sse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=core2 -quiet -dumpbase test.f90 -auxbase test -version -fintrinsic-modules-path /data/vondele/gcc_bench/gcc_trunk/build/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/finclude -o /dev/shm/vondele/ccQUXDFx.s
f951: error: unrecognized command line option ‘-mno-msse4.2’


/proc/cpuinfo has:

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz
stepping        : 6
Comment 9 Jakub Jelinek 2011-05-25 07:12:21 UTC
Author: jakub
Date: Wed May 25 07:12:17 2011
New Revision: 174171

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174171
Log:
	PR target/49128
	* config/i386/driver-i386.c (host_detect_local_cpu): Fix a typo.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/driver-i386.c
Comment 10 Joost VandeVondele 2011-05-25 11:34:48 UTC
(In reply to comment #9)
> Author: jakub
> Date: Wed May 25 07:12:17 2011
> New Revision: 174171
> 
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174171
> Log:
>     PR target/49128
>     * config/i386/driver-i386.c (host_detect_local_cpu): Fix a typo.
> 
> Modified:
>     trunk/gcc/ChangeLog
>     trunk/gcc/config/i386/driver-i386.c

FYI, the same bug made it to the 4.6 branch.
Comment 11 Jakub Jelinek 2011-05-25 11:54:01 UTC
Author: jakub
Date: Wed May 25 11:53:58 2011
New Revision: 174184

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174184
Log:
	PR target/49128
	* config/i386/driver-i386.c (host_detect_local_cpu): Fix a typo.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/driver-i386.c
Comment 12 Joost VandeVondele 2011-05-25 13:08:53 UTC
fixed