From patchwork Thu Jul 22 21:31:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 59647 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 9600D1007D4 for ; Fri, 23 Jul 2010 07:31:18 +1000 (EST) Received: (qmail 10469 invoked by alias); 22 Jul 2010 21:31:16 -0000 Received: (qmail 10460 invoked by uid 22791); 22 Jul 2010 21:31:15 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_AV, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vw0-f47.google.com (HELO mail-vw0-f47.google.com) (209.85.212.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Jul 2010 21:31:11 +0000 Received: by vws13 with SMTP id 13so646661vws.20 for ; Thu, 22 Jul 2010 14:31:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.163.10 with SMTP id y10mr1137229vcx.63.1279834267587; Thu, 22 Jul 2010 14:31:07 -0700 (PDT) Received: by 10.220.190.200 with HTTP; Thu, 22 Jul 2010 14:31:07 -0700 (PDT) In-Reply-To: <20100722212738.GA13339@intel.com> References: <20100722212738.GA13339@intel.com> Date: Thu, 22 Jul 2010 14:31:07 -0700 Message-ID: Subject: Re: PATCH: Check AVX runtime support From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak X-IsSubscribed: yes 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 On Thu, Jul 22, 2010 at 2:27 PM, H.J. Lu wrote: > AVX tests needs bit_OSXSAVE enabled.  We can check it in each test or > we can put it in check_effective_target_avx.  This patch adds bit_OSXSAVE > check to check_effective_target_avx. > > > H.J. > --- > 2010-07-22  H.J. Lu   > >        * lib/target-supports.exp (check_effective_target_avx): Check >        AVX runtime support. > This patch uses -O0 for unused function foo. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 9c1369a..9bb0816 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -3323,15 +3323,28 @@ proc check_effective_target_automatic_stack_alignment { } { } } -# Return 1 if avx instructions can be compiled. +# Return 1 if avx instructions can be compiled and run. proc check_effective_target_avx { } { - return [check_no_compiler_messages avx object { - void _mm256_zeroall (void) + return [check_runtime avx { + #include + + /* Check if assembler accepts AVX instructons. */ + void foo (void) { - __builtin_ia32_vzeroall (); + __asm__ volatile ("vzeroall"); + } + int main () + { + unsigned int eax, ebx, ecx, edx; + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return 1; + + /* Run AVX test only if host has AVX runtime support. */ + return ((ecx & (bit_AVX | bit_OSXSAVE)) + == (bit_AVX | bit_OSXSAVE)) ? 0 : 1; } - } "-O2 -mavx" ] + } "-O0" ] } # Return 1 if sse instructions can be compiled.