From patchwork Mon Jan 31 14:32:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 81119 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 EA660B70EA for ; Tue, 1 Feb 2011 01:33:02 +1100 (EST) Received: (qmail 26054 invoked by alias); 31 Jan 2011 14:33:00 -0000 Received: (qmail 26037 invoked by uid 22791); 31 Jan 2011 14:32:59 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_AV, TW_ZJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 31 Jan 2011 14:32:54 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id C56A67E3; Mon, 31 Jan 2011 15:32:51 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id tJmZAJARiDkq; Mon, 31 Jan 2011 15:32:48 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 25E5E7E1; Mon, 31 Jan 2011 15:32:48 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p0VEWl5B013185; Mon, 31 Jan 2011 15:32:47 +0100 (MET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: [testsuite, 4.4/4.5] Backport dg-require-effective-target avx_runtime Date: Mon, 31 Jan 2011 15:32:47 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) MIME-Version: 1.0 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 I noticed that the gcc.dg/compat/vector-[12]b execution test fails on the 4.4 and 4.5 branches on Solaris 10 and 11/x86 with Sun as: ld.so.1: gcc-dg-compat-vector-1b-01.exe: fatal: gcc-dg-compat-vector-1b-01.exe: hardware capability (CA_SUNW_HW_1) unsupported: 0x20000000 [ AVX ] FAIL: gcc.dg/compat/vector-1b c_compat_x_tst.o-c_compat_y_tst.o execute This can be fixed by backporting the support for the avx_runtime effective-target keyword, which is what the following patch does. Bootstrapped without regressions on i386-pc-solaris2.11 on the 4.5 branch. Ok for 4.5 branch now and the 4.4 branch after testing? Rainer 2011-01-28 Rainer Orth Backport from mainline: 2010-07-23 Uros Bizjak * lib/target-supports.exp (check_avx_hw_available): New procedure. (check_effective_target_avx_runtime): New procedure. * gcc.dg/compat/vector-1b_main.c: Use avx_runtime effective target. Remove cpuid.h include and __get_cpuid test. * gcc.dg/compat/vector-2b_main.c: Ditto. * gcc.target/i386/avx-check.h (main): Also check bit_OSXSAVE. diff -r c7d4df667a37 gcc/testsuite/gcc.dg/compat/vector-1b_main.c --- a/gcc/testsuite/gcc.dg/compat/vector-1b_main.c Fri Jan 28 21:44:51 2011 +0100 +++ b/gcc/testsuite/gcc.dg/compat/vector-1b_main.c Fri Jan 28 21:57:53 2011 +0100 @@ -1,12 +1,10 @@ /* { dg-skip-if "test AVX vector" { ! { i?86-*-* x86_64-*-* } } } */ -/* { dg-require-effective-target avx } */ +/* { dg-require-effective-target avx_runtime } */ /* Test compatibility of vector types: layout between separately-compiled modules, parameter passing, and function return. This test uses vectors of integer values. */ -#include "cpuid.h" - extern void vector_1_x (void); extern void exit (int); int fails; @@ -14,14 +12,6 @@ int main () { - unsigned int eax, ebx, ecx, edx; - - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) - return 0; - - /* Run AVX vector test only if host has AVX support. */ - if (ecx & bit_AVX) - vector_1_x (); - + vector_1_x (); exit (0); } diff -r c7d4df667a37 gcc/testsuite/gcc.dg/compat/vector-2b_main.c --- a/gcc/testsuite/gcc.dg/compat/vector-2b_main.c Fri Jan 28 21:44:51 2011 +0100 +++ b/gcc/testsuite/gcc.dg/compat/vector-2b_main.c Fri Jan 28 21:57:53 2011 +0100 @@ -1,12 +1,10 @@ /* { dg-skip-if "test AVX support" { ! { i?86-*-* x86_64-*-* } } } */ -/* { dg-require-effective-target avx } */ +/* { dg-require-effective-target avx_runtime } */ /* Test compatibility of vector types: layout between separately-compiled modules, parameter passing, and function return. This test uses vectors of floating points values. */ -#include "cpuid.h" - extern void vector_2_x (void); extern void exit (int); int fails; @@ -14,14 +12,6 @@ int main () { - unsigned int eax, ebx, ecx, edx; - - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) - return 0; - - /* Run AVX vector test only if host has AVX support. */ - if (ecx & bit_AVX) - vector_2_x (); - + vector_2_x (); exit (0); } diff -r c7d4df667a37 gcc/testsuite/gcc.target/i386/avx-check.h --- a/gcc/testsuite/gcc.target/i386/avx-check.h Fri Jan 28 21:44:51 2011 +0100 +++ b/gcc/testsuite/gcc.target/i386/avx-check.h Fri Jan 28 21:57:53 2011 +0100 @@ -20,7 +20,7 @@ return 0; /* Run AVX test only if host has AVX support. */ - if (ecx & bit_AVX) + if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE)) { do_test (); #ifdef DEBUG diff -r c7d4df667a37 gcc/testsuite/lib/target-supports.exp --- a/gcc/testsuite/lib/target-supports.exp Fri Jan 28 21:44:51 2011 +0100 +++ b/gcc/testsuite/lib/target-supports.exp Fri Jan 28 21:57:53 2011 +0100 @@ -1,5 +1,5 @@ -# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1005,6 +1005,30 @@ }] } +# Return 1 if the target supports executing AVX instructions, 0 +# otherwise. Cache the result. + +proc check_avx_hw_available { } { + return [check_cached_effective_target avx_hw_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_runtime_nocache avx_hw_available { + #include "cpuid.h" + int main () + { + unsigned int eax, ebx, ecx, edx; + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return ((ecx & (bit_AVX | bit_OSXSAVE)) + != (bit_AVX | bit_OSXSAVE)); + return 1; + } + } "" + } + }] +} + # Return 1 if the target supports running SSE executables, 0 otherwise. proc check_effective_target_sse_runtime { } { @@ -1025,6 +1049,16 @@ } } +# Return 1 if the target supports running AVX executables, 0 otherwise. + +proc check_effective_target_avx_runtime { } { + if { [check_effective_target_avx] + && [check_avx_hw_available] } { + return 1 + } + return 0 +} + # Return 1 if the target supports executing VSX instructions, 0 # otherwise. Cache the result.