From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19437 invoked by alias); 13 Nov 2012 05:21:03 -0000 Received: (qmail 19369 invoked by uid 48); 13 Nov 2012 05:20:45 -0000 From: "luto at mit dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/55307] New: libgcc's __cpu_indicator_init does not check for avx correctly Date: Tue, 13 Nov 2012 05:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luto at mit dot edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg01102.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55307 Bug #: 55307 Summary: libgcc's __cpu_indicator_init does not check for avx correctly Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned@gcc.gnu.org ReportedBy: luto@mit.edu [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/