From patchwork Thu Nov 7 19:44:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 289470 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 19DA52C00B8 for ; Fri, 8 Nov 2013 06:44:59 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=PHcwRgEqI2vGgqoxLqGFVWmX+Wopo/wi2IRSR/2bm4zuW2 x2XItOaPP4ojqGkX0DeywqlpUsMCfMyBDkJ9soIDXHbS5Vw6KGs5t7mLmu3ygjbQ M+AEbUMDf4WUMf3vLynwzhVcfrXwZHULniQWnTO3HLrXbolIrBAVyaB317UNA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=s/h3xKtKX+krcRq5Y7otNYzg4Yc=; b=uSBDARk2yUopa/bNLmaP xTYrzBE8NazXunlEWcd301ElTsDIAoS4LOKLLLxI32r1kSc1H0e/MCXjRR2xow9p OXNnFDIghYODJXhcCEz7AfiEacwraA8Kflo6OGZboHcSyF5POEj+3QGlVF0HAZAo hTFstVDCEOQesZOOOO9WNOQ= Received: (qmail 10897 invoked by alias); 7 Nov 2013 19:44:49 -0000 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 Received: (qmail 10884 invoked by uid 89); 7 Nov 2013 19:44:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.3 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPAM_SUBJECT, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ob0-f175.google.com Received: from Unknown (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 07 Nov 2013 19:44:48 +0000 Received: by mail-ob0-f175.google.com with SMTP id va2so548714obc.20 for ; Thu, 07 Nov 2013 11:44:40 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.44.36 with SMTP id b4mr1288123oem.53.1383853480321; Thu, 07 Nov 2013 11:44:40 -0800 (PST) Received: by 10.182.137.136 with HTTP; Thu, 7 Nov 2013 11:44:40 -0800 (PST) Date: Thu, 7 Nov 2013 20:44:40 +0100 Message-ID: Subject: [PATCH i386]: Handle FP_EX_DENORM and improve __sfp_handle_exceptions From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" Hello! Attached patch adds missing FP_EX_DENORM handling to x86 soft-fp exception generator and improves support code a bit. The FP_EX_DENORM handling will be needed by gfortran IEEE support. 2013-11-07 Uros Bizjak * config/i386/sfp-exceptions.c (__sfp_handle_exceptions): Handle FP_EX_DENORM. Store result to volatile location after SSE division to close interrupt window. Remove unneeded fwait after x87 division since interrupt window will be closed by emitted fstp. Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. The patch will be backported to other release branches due to missing FP_EX_DENORM. Uros. Index: config/i386/sfp-exceptions.c =================================================================== --- config/i386/sfp-exceptions.c (revision 204522) +++ config/i386/sfp-exceptions.c (working copy) @@ -48,20 +48,32 @@ { float f = 0.0f; #ifdef __x86_64__ + volatile float r; asm volatile ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f)); + r = f; /* Needed to trigger exception. */ #else asm volatile ("fdiv\t{%y0, %0|%0, %y0}" : "+t" (f)); - asm volatile ("fwait"); + /* No need for fwait, exception is triggered by emitted fstp. */ #endif } + if (_fex & FP_EX_DENORM) + { + struct fenv temp; + asm volatile ("fnstenv\t%0" : "=m" (temp)); + temp.__status_word |= FP_EX_DENORM; + asm volatile ("fldenv\t%0" : : "m" (temp)); + asm volatile ("fwait"); + } if (_fex & FP_EX_DIVZERO) { float f = 1.0f, g = 0.0f; #ifdef __x86_64__ + volatile float r; asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g)); + r = f; /* Needed to trigger exception. */ #else asm volatile ("fdivs\t%1" : "+t" (f) : "m" (g)); - asm volatile ("fwait"); + /* No need for fwait, exception is triggered by emitted fstp. */ #endif } if (_fex & FP_EX_OVERFLOW)