From patchwork Thu Jul 21 15:52:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 106087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D4F88B6F75 for ; Fri, 22 Jul 2011 01:53:14 +1000 (EST) Received: (qmail 18090 invoked by alias); 21 Jul 2011 15:53:11 -0000 Received: (qmail 18075 invoked by uid 22791); 21 Jul 2011 15:53:09 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_ZJ, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jul 2011 15:52:35 +0000 Received: by pvf24 with SMTP id 24so1415307pvf.20 for ; Thu, 21 Jul 2011 08:52:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.36.165 with SMTP id r5mr509068pbj.296.1311263553330; Thu, 21 Jul 2011 08:52:33 -0700 (PDT) Received: by 10.142.89.19 with HTTP; Thu, 21 Jul 2011 08:52:33 -0700 (PDT) Date: Thu, 21 Jul 2011 17:52:33 +0200 Message-ID: Subject: [PATCH, testsuite]: Introduce check_avx_os_support_available From: Uros Bizjak To: gcc-patches@gcc.gnu.org Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello! This is the same functionality as recently added to glibc [1]. 2011-07-21 Uros Bizjak * lib/target-supports.exp (check_avx_os_support_available): New. (check_effective_target_avx_runtime): Use it. Tested on x86_64-pc-linux-gnu {,-m32} AVX and non-AVX targets, ommitted to mainline SVN. The patch will be backported to release branches. [1] http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=5644ef5461b5d3ff266206d8ee70d4b575ea6658 Uros. Index: lib/target-supports.exp =================================================================== --- lib/target-supports.exp (revision 176571) +++ lib/target-supports.exp (working copy) @@ -1070,8 +1070,8 @@ check_runtime_nocache sse_os_support_available { int main () { - __asm__ volatile ("movaps %xmm0,%xmm0"); - return 0; + asm volatile ("movaps %xmm0,%xmm0"); + return 0; } } "-msse" } else { @@ -1080,6 +1080,29 @@ }] } +# Return 1 if the target OS supports running AVX executables, 0 +# otherwise. Cache the result. + +proc check_avx_os_support_available { } { + return [check_cached_effective_target avx_os_support_available { + # If this is not the right target then we can skip the test. + if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } { + expr 0 + } else { + # Check that OS has AVX and SSE saving enabled. + check_runtime_nocache avx_os_support_available { + int main () + { + unsigned int eax, edx; + + asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0)); + return (eax & 6) != 6; + } + } "" + } + }] +} + # Return 1 if the target supports executing SSE instructions, 0 # otherwise. Cache the result. @@ -1176,7 +1199,8 @@ proc check_effective_target_avx_runtime { } { if { [check_effective_target_avx] - && [check_avx_hw_available] } { + && [check_avx_hw_available] + && [check_avx_os_support_available] } { return 1 } return 0