From patchwork Mon Aug 30 14:40:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 63044 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 7A491B70EE for ; Tue, 31 Aug 2010 00:40:30 +1000 (EST) Received: (qmail 3895 invoked by alias); 30 Aug 2010 14:40:27 -0000 Received: (qmail 3877 invoked by uid 22791); 30 Aug 2010 14:40:25 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Aug 2010 14:40:20 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 30 Aug 2010 07:40:16 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by orsmga001.jf.intel.com with ESMTP; 30 Aug 2010 07:40:16 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 6F6B6224F5; Mon, 30 Aug 2010 07:40:16 -0700 (PDT) Date: Mon, 30 Aug 2010 07:40:16 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak , Maxim Kuvyrkov Subject: PATCH: Enable TARGET_HAS_SINCOS if x87 FPU fsincos is available Message-ID: <20100830144016.GA31228@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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 Hi, On x86, sincos is always available if x87 FPU fsincos is available. This patch enables TARGET_HAS_SINCOS for -ffast-math and x87 FPU. Also x86 Bionic C library doesn't provide sincos and we shouldn't enable TARGET_HAS_SINCOS with OPTION_BIONIC on x86. OK for trunk? Thanks. H.J. --- 2010-08-30 H.J. Lu * config/linux.h (TARGET_HAS_SINCOS): Define only if not defined. * config/i386/i386.h (TARGET_HAS_SINCOS): New. Enabled if x87 FPU fsincos is available. * config/i386/x86-64.h (TARGET_HAS_SINCOS): Likewise. * config/i386/linux.h (TARGET_HAS_SINCOS): Likewise. * config/i386/linux64.h (TARGET_HAS_SINCOS): Likewise. diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 5bae99d..493b5d2 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2492,6 +2492,12 @@ struct GTY(()) machine_function { #undef TARG_COND_NOT_TAKEN_BRANCH_COST #define TARG_COND_NOT_TAKEN_BRANCH_COST ix86_cost->cond_not_taken_branch_cost +/* Use x87 FPU fsincos if it is available. */ +#undef TARGET_HAS_SINCOS +#define TARGET_HAS_SINCOS \ + (flag_unsafe_math_optimizations \ + && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387)) + /* Local variables: version-control: t diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h index 2a31880..f466d6d 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -35,6 +35,15 @@ along with GCC; see the file COPYING3. If not see #undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS +/* Whether we have sincos that follows the GNU extension. There is no + sincos in Bionic C library. We can only use x87 FPU fsincos if it + is available. */ +#undef TARGET_HAS_SINCOS +#define TARGET_HAS_SINCOS \ + (OPTION_GLIBC \ + || (flag_unsafe_math_optimizations \ + && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387))) + #undef ASM_COMMENT_START #define ASM_COMMENT_START "#" diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h index 867de59..9f38a57 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -50,6 +50,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS +/* Whether we have sincos that follows the GNU extension. There is no + sincos in Bionic C library. We can only use x87 FPU fsincos if it + is available. */ +#undef TARGET_HAS_SINCOS +#define TARGET_HAS_SINCOS \ + (OPTION_GLIBC \ + || (flag_unsafe_math_optimizations \ + && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387))) + /* Provide a LINK_SPEC. Here we provide support for the special GCC options -static and -shared, which allow us to link things in one of these three modes by applying the appropriate combinations of diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h index 1b64813..d18ec23 100644 --- a/gcc/config/i386/x86-64.h +++ b/gcc/config/i386/x86-64.h @@ -107,3 +107,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #undef TARGET_ASM_UNIQUE_SECTION #define TARGET_ASM_UNIQUE_SECTION x86_64_elf_unique_section + +/* Use x87 FPU fsincos if it is available. */ +#undef TARGET_HAS_SINCOS +#define TARGET_HAS_SINCOS \ + (flag_unsafe_math_optimizations \ + && (!TARGET_SSE_MATH || TARGET_MIX_SSE_I387)) diff --git a/gcc/config/linux.h b/gcc/config/linux.h index e283a9a..576a2ac 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -159,7 +159,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see is present in the runtime library. */ #define TARGET_C99_FUNCTIONS (OPTION_GLIBC) +#ifndef TARGET_HAS_SINCOS /* Whether we have sincos that follows the GNU extension. */ #define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC) +#endif #define TARGET_POSIX_IO