From patchwork Mon Aug 30 15:53:58 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: 63063 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 44DF9B6EDD for ; Tue, 31 Aug 2010 01:54:45 +1000 (EST) Received: (qmail 29477 invoked by alias); 30 Aug 2010 15:54:39 -0000 Received: (qmail 29453 invoked by uid 22791); 30 Aug 2010 15:54:35 -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 X-Spam-Check-By: sourceware.org Received: from mail-ew0-f47.google.com (HELO mail-ew0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Aug 2010 15:54:01 +0000 Received: by ewy7 with SMTP id 7so3569076ewy.20 for ; Mon, 30 Aug 2010 08:53:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.181.15 with SMTP id i15mr380884mup.122.1283183638646; Mon, 30 Aug 2010 08:53:58 -0700 (PDT) Received: by 10.220.78.193 with HTTP; Mon, 30 Aug 2010 08:53:58 -0700 (PDT) In-Reply-To: References: <20100830144016.GA31228@intel.com> Date: Mon, 30 Aug 2010 08:53:58 -0700 Message-ID: Subject: Re: PATCH: Enable TARGET_HAS_SINCOS if x87 FPU fsincos is available From: "H.J. Lu" To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, Uros Bizjak , Maxim Kuvyrkov 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 Mon, Aug 30, 2010 at 7:57 AM, Richard Guenther wrote: > On Mon, Aug 30, 2010 at 4:40 PM, H.J. Lu wrote: >> 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? > > Hm.  Shouldn't it be conditional on USE_FANCY_MATH_387 > && !NO_FANCY_MATH_387 as well? You are right. Here is the updated patch. > Also a flag dependency breaks with the target/option attributes, The current target/option attributes have many problems. It shouldn't prevent us from generating better codes. > so I'm not sure it is a good idea.  Does anyone care for FP > execution performance on 32bit anyway? > Intel cares FP execution performance on 32bit Thanks. diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 5bae99d..16a17c4 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2492,6 +2492,13 @@ 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 \ + (TARGET_USE_FANCY_MATH_387 \ + && 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..42db416 100644 --- a/gcc/config/i386/linux.h +++ b/gcc/config/i386/linux.h @@ -35,6 +35,16 @@ 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 \ + || (TARGET_USE_FANCY_MATH_387 \ + && 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..7bc12b7 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -50,6 +50,16 @@ 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 \ + || (TARGET_USE_FANCY_MATH_387 \ + && 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/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