public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
@ 2011-04-23 21:09 gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:12 ` [Bug target/48743] " gcc.gnu.org at stellar dot eclipse.co.uk
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: gcc.gnu.org at stellar dot eclipse.co.uk @ 2011-04-23 21:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
Summary: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon -
compiled C fails with "illegal instruction"
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gcc.gnu.org@stellar.eclipse.co.uk
Created attachment 24084
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24084
Output of `echo | gcc -dM -E - -march=native`
When I compile nano on my Linux system using `-march=i586`, `-march=k6-2` or
`-march=k6-3` it works fine.
If I compile it with `-march=native` then nano crashes on startup saying
"illegal instruction".
/proc/cpuinfo seems to show the CPU correctly:
# cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 5
model : 13
model name : AMD-K6(tm)-III Processor
stepping : 4
cpu MHz : 448.140
cache size : 128 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 vme de pse tsc msr cx8 pge mmx syscall 3dnowext 3dnow
k6_mtrr
bogomips : 896.28
clflush size : 32
cache_alignment : 32
address sizes : 32 bits physical, 32 bits virtual
power management: ts fid vid
However gcc seems to misdetect it:
# gcc -v -Q --help=target -march=native 2>&1 | grep march
/usr/libexec/gcc/i586-pc-linux-gnu/4.5.2/cc1 -v help-dummy -D_FORTIFY_SOURCE=2
-march=athlon --param l1-cache-size=32 --param l1-cache-line-size=32 --param
l2-cache-size=128 -mtune=athlon -dumpbase help-dummy -auxbase help-dummy
-version -fhelp=target -o /tmp/ccQrke9q.s
-march= athlon
# cc -march=native -E -v - </dev/null 2>&1 | grep cc1
/usr/libexec/gcc/i586-pc-linux-gnu/4.5.2/cc1 -E -quiet -v -
-D_FORTIFY_SOURCE=2 -march=athlon --param l1-cache-size=32 --param
l1-cache-line-size=32 --param l2-cache-size=128 -mtune=athlon
Output of `echo | gcc -dM -E - -march=native` attached.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
@ 2011-04-23 21:12 ` gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:14 ` gcc.gnu.org at stellar dot eclipse.co.uk
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gcc.gnu.org at stellar dot eclipse.co.uk @ 2011-04-23 21:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #1 from Joe Stroller <gcc.gnu.org at stellar dot eclipse.co.uk> 2011-04-23 21:12:35 UTC ---
Created attachment 24085
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24085
Output from Todd Allen's cpuid utility
Todd Allen's cpuid utility detects this CPU correctly.
http://www.etallen.com/cpuid.html
Output attached.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:12 ` [Bug target/48743] " gcc.gnu.org at stellar dot eclipse.co.uk
@ 2011-04-23 21:14 ` gcc.gnu.org at stellar dot eclipse.co.uk
2011-05-12 8:59 ` zuxy.meng at gmail dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gcc.gnu.org at stellar dot eclipse.co.uk @ 2011-04-23 21:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #2 from Joe Stroller <gcc.gnu.org at stellar dot eclipse.co.uk> 2011-04-23 21:14:26 UTC ---
Created attachment 24086
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24086
Raw output from Todd Allen's cpuid utility
Raw output also attached.
I think the AMD document "AMD Processor Recognition Application Note" may also
be relevant:
http://support.amd.com/us/Processor_TechDocs/20734.pdf
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:12 ` [Bug target/48743] " gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:14 ` gcc.gnu.org at stellar dot eclipse.co.uk
@ 2011-05-12 8:59 ` zuxy.meng at gmail dot com
2011-05-22 14:46 ` mikpe at it dot uu.se
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: zuxy.meng at gmail dot com @ 2011-05-12 8:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #3 from Zuxy <zuxy.meng at gmail dot com> 2011-05-12 08:27:56 UTC ---
Created attachment 24233
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24233
Proposed patch
For a brief time AMD produced K6-2+ and K6-3+ processors, targeting mobile
market. These processors support Extended 3DNow! but not CMOV or Extended MMX
(a subset of SSE) and are detected as Athlon by GCC so GCC will generate CMOV
for them, leading to #UD.
The patch solves the problem by differentiating K6 and Athlon by Extended MMX
rather than Extended 3DNow!.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (2 preceding siblings ...)
2011-05-12 8:59 ` zuxy.meng at gmail dot com
@ 2011-05-22 14:46 ` mikpe at it dot uu.se
2011-06-16 15:10 ` gcc.gnu.org at stellar dot eclipse.co.uk
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mikpe at it dot uu.se @ 2011-05-22 14:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #4 from Mikael Pettersson <mikpe at it dot uu.se> 2011-05-22 14:23:21 UTC ---
Created attachment 24326
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24326
untested fix
The previous patch doesn't look quite right to me. The fundamental problem IMO
is that the AMD CPU type detection only looks at feature flags without
considering the CPUID family value. This (untested) patch qualifies the
ambiguous feature test with a family test before assuming CPU == Athlon.
Does this solve your problem?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (3 preceding siblings ...)
2011-05-22 14:46 ` mikpe at it dot uu.se
@ 2011-06-16 15:10 ` gcc.gnu.org at stellar dot eclipse.co.uk
2011-12-19 18:03 ` qneill at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gcc.gnu.org at stellar dot eclipse.co.uk @ 2011-06-16 15:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #5 from Joe Stroller <gcc.gnu.org at stellar dot eclipse.co.uk> 2011-06-16 15:10:30 UTC ---
(In reply to comment #4)
> Does this solve your problem?
Yes! Thank you, Mikael, and apologies for not testing sooner.
The fix in attachment 24326 works perfectly.
I tested it on gcc 4.5.2, and the "if" that is changed is at line 509 on that
version, but the structure is exactly the same.
Now:
# echo | gcc -dM -E - -march=native gcc -v -Q --help=target -march=native 2>&1
| grep march
/usr/libexec/gcc/i586-pc-linux-gnu/4.5.2/cc1 -E -v help-dummy
-D_FORTIFY_SOURCE=2 -march=k6-3 --param l1-cache-size=32 --param
l1-cache-line-size=32 --param l2-cache-size=128 -mtune=k6 -fhelp=target -dM
-march= k6-3
# cc -march=native -E -v - </dev/null 2>&1 | grep cc1
/usr/libexec/gcc/i586-pc-linux-gnu/4.5.2/cc1 -E -quiet -v -
-D_FORTIFY_SOURCE=2 -march=k6-3 --param l1-cache-size=32 --param
l1-cache-line-size=32 --param l2-cache-size=128 -mtune=k6
#
Additionally I have recompiled my whole system with -march=native, and it is
working perfectly.
I would be very grateful if this were able to be incorporated into gcc.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (4 preceding siblings ...)
2011-06-16 15:10 ` gcc.gnu.org at stellar dot eclipse.co.uk
@ 2011-12-19 18:03 ` qneill at gcc dot gnu.org
2011-12-19 18:57 ` qneill at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: qneill at gcc dot gnu.org @ 2011-12-19 18:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #6 from Quentin Neill <qneill at gcc dot gnu.org> 2011-12-19 17:57:42 UTC ---
Author: qneill
Date: Mon Dec 19 17:57:32 2011
New Revision: 182489
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182489
Log:
2011-12-19 Quentin Neill <quentin.neill@amd.com>
2011-12-19 Quentin Neill <quentin.neill@amd.com>
PR target/48743
* config/i386/driver-i386.c (host_detect_local_cpu): Also check
family to distinguish PROCESSOR_ATHLON.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/driver-i386.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (5 preceding siblings ...)
2011-12-19 18:03 ` qneill at gcc dot gnu.org
@ 2011-12-19 18:57 ` qneill at gcc dot gnu.org
2012-01-19 20:23 ` qneill at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: qneill at gcc dot gnu.org @ 2011-12-19 18:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
Quentin Neill <qneill at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |qneill at gcc dot gnu.org
--- Comment #7 from Quentin Neill <qneill at gcc dot gnu.org> 2011-12-19 18:55:49 UTC ---
Waiting to fix in 4.5 and 4.6 per Uros:
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00938.html
Meanwhile, fixed in trunk (4.7) after testing on amdfam10 and bdver1:
Author: qneill
Date: Mon Dec 19 17:57:32 2011
New Revision: 182489
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182489
Log:
2011-12-19 Quentin Neill <quentin.neill@amd.com>
2011-12-19 Quentin Neill <quentin.neill@amd.com>
PR target/48743
* config/i386/driver-i386.c (host_detect_local_cpu): Also check
family to distinguish PROCESSOR_ATHLON.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/driver-i386.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (6 preceding siblings ...)
2011-12-19 18:57 ` qneill at gcc dot gnu.org
@ 2012-01-19 20:23 ` qneill at gcc dot gnu.org
2012-02-07 16:18 ` qneill at gcc dot gnu.org
2012-02-08 10:45 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: qneill at gcc dot gnu.org @ 2012-01-19 20:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #8 from Quentin Neill <qneill at gcc dot gnu.org> 2012-01-19 20:15:38 UTC ---
Author: qneill
Date: Thu Jan 19 20:15:29 2012
New Revision: 183309
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183309
Log:
2012-01-19 Quentin Neill <quentin.neill@amd.com>
PR target/48743
* config/i386/driver-i386.c (host_detect_local_cpu): Also check
family to distinguish PROCESSOR_ATHLON.
Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/config/i386/driver-i386.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (7 preceding siblings ...)
2012-01-19 20:23 ` qneill at gcc dot gnu.org
@ 2012-02-07 16:18 ` qneill at gcc dot gnu.org
2012-02-08 10:45 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: qneill at gcc dot gnu.org @ 2012-02-07 16:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
--- Comment #9 from Quentin Neill <qneill at gcc dot gnu.org> 2012-02-07 16:17:35 UTC ---
Author: qneill
Date: Tue Feb 7 16:17:26 2012
New Revision: 183973
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183973
Log:
2012-02-07 Quentin Neill <quentin.neill@amd.com>
Backport from mainline:
2012-01-19 Quentin Neill <quentin.neill@amd.com>
PR target/48743
* config/i386/driver-i386.c (host_detect_local_cpu): Also check
family to distinguish PROCESSOR_ATHLON.
Modified:
branches/gcc-4_5-branch/gcc/ChangeLog
branches/gcc-4_5-branch/gcc/config/i386/driver-i386.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/48743] -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction"
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
` (8 preceding siblings ...)
2012-02-07 16:18 ` qneill at gcc dot gnu.org
@ 2012-02-08 10:45 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-08 10:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48743
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.5.4
--- Comment #10 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-08 10:45:35 UTC ---
Fixed for 4.5.4.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-02-08 10:45 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-23 21:09 [Bug target/48743] New: -march=native mis-detects AMD K6-2+ / K6-3 as Athlon - compiled C fails with "illegal instruction" gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:12 ` [Bug target/48743] " gcc.gnu.org at stellar dot eclipse.co.uk
2011-04-23 21:14 ` gcc.gnu.org at stellar dot eclipse.co.uk
2011-05-12 8:59 ` zuxy.meng at gmail dot com
2011-05-22 14:46 ` mikpe at it dot uu.se
2011-06-16 15:10 ` gcc.gnu.org at stellar dot eclipse.co.uk
2011-12-19 18:03 ` qneill at gcc dot gnu.org
2011-12-19 18:57 ` qneill at gcc dot gnu.org
2012-01-19 20:23 ` qneill at gcc dot gnu.org
2012-02-07 16:18 ` qneill at gcc dot gnu.org
2012-02-08 10:45 ` rguenth at gcc dot gnu.org
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).