From patchwork Thu Jan 24 13:08:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 215348 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 44C1E2C008C for ; Fri, 25 Jan 2013 00:08:58 +1100 (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=1359637739; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=99bhLxc jUa7R8hypF5u6azz5rWU=; b=gnVT6siRMraGh6/PZldJUtBJlODyVKE3ErjrE+7 JA/tnwz0Be3V7ysc3f5zYAYUNVRjOtEcvqARnOh6axo1VCE9l4u6rKucAouN6mcx wH3R0x7vUK00iqzgdE2yIwTy/vTKnQPt63bmJFjjADJAcINsF87RZFujKMShAI+u UQUY= 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:X-Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=VXNhPs3nwnw+os8sJ4cRJ7aUKFpEPfkXGyGTCtjruM/zkkJzgNqlw1euT+4DjB 03lI7Drwr+wRLh6lorE9i2Lz8U3Mhh0rpgqOBs6CgayTDDWi/ybhwyDT1ckOIwhh yN8PAZMuWwUIOROazqD7z5Jn83I7A14Em5TKTQPDKgAGM=; Received: (qmail 19305 invoked by alias); 24 Jan 2013 13:08:50 -0000 Received: (qmail 19196 invoked by uid 22791); 24 Jan 2013 13:08:48 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-oa0-f48.google.com (HELO mail-oa0-f48.google.com) (209.85.219.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jan 2013 13:08:41 +0000 Received: by mail-oa0-f48.google.com with SMTP id h2so9701435oag.21 for ; Thu, 24 Jan 2013 05:08:40 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.0.138 with SMTP id 10mr1305753oee.142.1359032919666; Thu, 24 Jan 2013 05:08:39 -0800 (PST) Received: by 10.182.49.68 with HTTP; Thu, 24 Jan 2013 05:08:39 -0800 (PST) Date: Thu, 24 Jan 2013 14:08:39 +0100 Message-ID: Subject: [PATCH, i386]: Disable x87 register preferences in mov{sf, df} patterns for -mfpmath=sse From: Uros Bizjak To: gcc-patches@gcc.gnu.org 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, Jan 23, 2013 at 8:08 PM, Uros Bizjak wrote: > All things equal, we would like to avoid x87 registers to move DFmode > immediates to a memory. Attached patch is much better fix for the above problem. The patch conditionally disables x87 register preferences when -mfpmath=sse is in effect. 2013-01-24 Uros Bizjak * config/i386/constraints.md (Yf): New constraint. * config/i386/i386.md (*movdf_internal_rex64): Use Yf*f instead of f constraint to conditionaly disable x87 register preferences. (*movdf_internal): Ditto. (*movsf_internal): Ditto. testsuite/ChangeLog: 2013-01-24 Uros Bizjak * gcc.target/i386/movsd.c: New test. Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN. Uros. Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 195417) +++ config/i386/i386.md (working copy) @@ -2934,9 +2934,9 @@ (define_insn "*movdf_internal_rex64" [(set (match_operand:DF 0 "nonimmediate_operand" - "=?f,?m,?f,?r,?m,?r,x,x,x,m,Yi,r ") + "=Yf*f,m ,Yf*f,?r ,?m,?r,x,x,x,m,Yi,r ") (match_operand:DF 1 "general_operand" - "fm ,f ,G ,rm,r ,F ,C,x,m,x,r ,Yi"))] + "Yf*fm,Yf*f,G ,rmC,rC,F ,C,x,m,x,r ,Yi"))] "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) @@ -3074,9 +3074,9 @@ ;; Possible store forwarding (partial memory) stall in alternative 4. (define_insn "*movdf_internal" [(set (match_operand:DF 0 "nonimmediate_operand" - "=f,m,f,?Yd*r ,!o ,x,x,x,m,*x,*x,*x,m") + "=Yf*f,m ,Yf*f,?Yd*r ,!o ,x,x,x,m,*x,*x,*x,m") (match_operand:DF 1 "general_operand" - "fm,f,G,Yd*roF,FYd*r,C,x,m,x,C ,*x,m ,*x"))] + "Yf*fm,Yf*f,G ,Yd*roF,Yd*rF,C,x,m,x,C ,*x,m ,*x"))] "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) @@ -3213,9 +3213,9 @@ (define_insn "*movsf_internal" [(set (match_operand:SF 0 "nonimmediate_operand" - "=f,m,f,?r ,?m,x,x,x,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r") + "=Yf*f,m ,Yf*f,?r ,?m,x,x,x,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r") (match_operand:SF 1 "general_operand" - "fm,f,G,rmF,Fr,C,x,m,x,m ,*y,*y ,r ,Yi,r ,*Ym"))] + "Yf*fm,Yf*f,G ,rmF,rF,C,x,m,x,m ,*y,*y ,r ,Yi,r ,*Ym"))] "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (!can_create_pseudo_p () || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) Index: config/i386/constraints.md =================================================================== --- config/i386/constraints.md (revision 195417) +++ config/i386/constraints.md (working copy) @@ -93,6 +93,7 @@ ;; p Integer register when TARGET_PARTIAL_REG_STALL is disabled ;; d Integer register when integer DFmode moves are enabled ;; x Integer register when integer XFmode moves are enabled +;; f x87 register when 80387 floating point arithmetic is enabled (define_register_constraint "Yz" "TARGET_SSE ? SSE_FIRST_REG : NO_REGS" "First SSE register (@code{%xmm0}).") @@ -124,6 +125,10 @@ "optimize_function_for_speed_p (cfun) ? GENERAL_REGS : NO_REGS" "@internal Any integer register when integer XFmode moves are enabled.") +(define_register_constraint "Yf" + "(ix86_fpmath & FPMATH_387) ? FLOAT_REGS : NO_REGS" + "@internal Any x87 register when 80387 FP arithmetic is enabled.") + (define_constraint "z" "@internal Constant call address operand." (match_operand 0 "constant_call_address_operand")) Index: testsuite/gcc.target/i386/movsd.c =================================================================== --- testsuite/gcc.target/i386/movsd.c (revision 0) +++ testsuite/gcc.target/i386/movsd.c (revision 0) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse2 -mfpmath=sse" } */ + +volatile double y; + +void +test () +{ + int z; + + for (z = 0; z < 1000; z++) + y = 1.23; +} + +/* { dg-final { scan-assembler-not "(fld|fst)" } } */