From patchwork Wed Sep 5 21:37:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 181962 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 18A9C2C0086 for ; Thu, 6 Sep 2012 07:38:16 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347485897; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=N/quiIehG/vIZAxThEJEcpdNevE=; b=uEDA4QlnGQqPhyinTGPN5DHCZqd+n1J1KUVobLQ+D+9r0tuLTeiwtpEOqjogmv 1wd9vRkNQHVuQ3dBoWKla+6OK1Fa3yiCrGvikw1GOXyVFK9sbanaStycSjvHG8Py cp7ciP5DOT8cMTXyLkVIok6YACep1rdbxmckIyciFX/7E= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=QrTe7RQum5CkRZ2OPitYDpcrIXI1U1oYTUBGmcWNRuN7m4yUYsrQS7GkmYvCBN csFzce99/KTHaJwtfc/5IdvKYM5H3YtZg5ahYv2P6lcbR5Gx4hDYROAR0TJ4EJLs TZc9W3scTvpecoSxfOXhtKmSZ4J1qIg3IzfVFpGqJfgzU=; Received: (qmail 423 invoked by alias); 5 Sep 2012 21:38:11 -0000 Received: (qmail 406 invoked by uid 22791); 5 Sep 2012 21:38:11 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SARE_SUB_6CONS_WORD, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Sep 2012 21:37:58 +0000 Received: by pbcwy7 with SMTP id wy7so1654143pbc.20 for ; Wed, 05 Sep 2012 14:37:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.84.39 with SMTP id v7mr18916407pay.57.1346881077693; Wed, 05 Sep 2012 14:37:57 -0700 (PDT) Received: by 10.66.20.232 with HTTP; Wed, 5 Sep 2012 14:37:57 -0700 (PDT) In-Reply-To: References: Date: Wed, 5 Sep 2012 23:37:57 +0200 Message-ID: Subject: Re: [PATCH, libgfortran]: Use __builtin_ia32_{stmxcsr, ldmxcsr} intrinsics in config/fpu-i387.h From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Fortran List 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 Wed, Sep 5, 2012 at 11:30 PM, Uros Bizjak wrote: >> * config/fpu-387.h (set_fpu): Use __builtin_ia32_stmxcsr and >> __builtin_ia32_ldmxcsr intrinsics. >> >> Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline an 4.7 branch. > > I forgot that these builtins are enabled for SSE only (and x86_64 > bootstrap enables SSE2 by default), so following addition is needed: > > --cut here-- > Index: config/fpu-387.h > =================================================================== > --- config/fpu-387.h (revision 190992) > +++ config/fpu-387.h (working copy) > @@ -96,7 +96,11 @@ > #define _FPU_MASK_UM 0x10 > #define _FPU_MASK_PM 0x20 > > -void set_fpu (void) > +void > +#ifndef __SSE__ > +__attribute__((__target__("sse"))) > +#endif > +set_fpu (void) > { > unsigned short cw; > > --cut here-- > > Re-tested on x86_64-pc-linux-gnu and committed. ... Not really. This option enables cmove, which should not be used on plain x86_32. At the end, lets revert back to assembly, with following change that was intended from the beginning: Sorry for troubles, Uros. Index: config/fpu-387.h =================================================================== --- config/fpu-387.h (revision 190992) +++ config/fpu-387.h (working copy) @@ -112,7 +112,7 @@ if (options.fpe & GFC_FPE_UNDERFLOW) cw &= ~_FPU_MASK_UM; if (options.fpe & GFC_FPE_INEXACT) cw &= ~_FPU_MASK_PM; - asm volatile ("fldcw %0" : : "m" (cw)); + asm volatile ("%vstmxcsr %0" : "=m" (cw_sse)); if (has_sse()) { @@ -131,6 +131,6 @@ if (options.fpe & GFC_FPE_UNDERFLOW) cw_sse &= ~(_FPU_MASK_UM << 7); if (options.fpe & GFC_FPE_INEXACT) cw_sse &= ~(_FPU_MASK_PM << 7); - __builtin_ia32_ldmxcsr (cw_sse); + asm volatile ("%vldmxcsr %0" : : "m" (cw_sse)); } }