Bug 55307 - libgcc's __cpu_indicator_init does not check for avx correctly
Summary: libgcc's __cpu_indicator_init does not check for avx correctly
Status: RESOLVED DUPLICATE of bug 85100
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-13 05:20 UTC by Andy Lutomirski
Modified: 2018-05-03 21:44 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-11-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Lutomirski 2012-11-13 05:20:44 UTC
[this is a libgcc bug, and I haven't tested it -- the test is a PITA.]

One might expect that __builtin_cpu_supports("avx") would only return true if avx is usable.  Unfortunately, it returns true iff avx is implemented by the cpu, regardless of whether it should be expected to work.  The code should check for osxsave and then use xgetbv to see if ymm state is available.

This is more or less the same bug as glibc bug 13007 [1].  There's an intel blog post on the subject at [2].  It's likely to result in crashes if old kernels are run on new hardware.

Curiously, the code in gcc/testsuite/gcc.target/i386/avx-check.h appears correct.  I suspect it's never been run with ymm state disabled.

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=13007
[2] http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled/
Comment 1 Jakub Jelinek 2013-03-22 14:45:13 UTC
GCC 4.8.0 is being released, adjusting target milestone.
Comment 2 Jakub Jelinek 2013-05-31 10:58:47 UTC
GCC 4.8.1 has been released.
Comment 3 Jakub Jelinek 2013-10-16 09:50:28 UTC
GCC 4.8.2 has been released.
Comment 4 Jeffrey Walton 2015-08-19 17:04:40 UTC
Forgive my ignorance... Is __builtin_cpu_supports really __builtin_os_supports? If we want to test CPU support (rather than OS support), then can it be done with the built-ins?

Also, the documentation at https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/X86-Built-in-Functions.html does not mention that this is in fact OS support, and not CPU support.
Comment 5 Nathaniel J. Smith 2018-05-03 20:36:00 UTC
This was fixed in #85100.
Comment 6 H.J. Lu 2018-05-03 21:43:41 UTC
Dup.
Comment 7 H.J. Lu 2018-05-03 21:44:04 UTC
Dup.

*** This bug has been marked as a duplicate of bug 85100 ***