From patchwork Thu Jul 16 09:24:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 496625 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 632C71402B1 for ; Thu, 16 Jul 2015 19:26:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Eaic+1My; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=kjMbyoq41liiF+3xt S/St/EhBuGw265r9ucdcXPXDGPg9kDgwUlR1Eb6GWl+Xvrt1rHXz3QBl7b9usl1y mBRCmt2GffNkccPXD6Ztk5SmA4d5NhZvE5icMZuLKHio6q3MdgG+RLJibde5WaR1 4eQckXnHa8QubYWi8BQjDsIs7Y= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=DSoqXOt6jM5JbVgJXv/+mZk Bb2w=; b=Eaic+1MyRAWdKFR27+yf/A5FP4CaTkiolOvL9V9rB8foBd35yNMWTIN 42tk75sO6huoEwuJsX6Ii6UJ1K8s540OYdduIqGC5h55Gc159Dx1xDUGl8g5eg5b BSn7Rs7d4uLrZPBpZMQIeIfKBItHZ/5yDlZxj0PhZVJauVGY89wo= Received: (qmail 5033 invoked by alias); 16 Jul 2015 09:25:57 -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 124563 invoked by uid 89); 16 Jul 2015 09:24:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jul 2015 09:24:25 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-18-uav1QrpiRFOB3mLeMSLQjg-1; Thu, 16 Jul 2015 10:24:20 +0100 Received: from [10.2.207.49] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Jul 2015 10:24:20 +0100 Message-ID: <55A77844.7000702@arm.com> Date: Thu, 16 Jul 2015 10:24:20 +0100 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: James Greenhalgh CC: "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan , Marcus Shawcroft Subject: Re: [PATCH][AArch64] PR target/66731 Fix fnmul insn with -frounding-math References: <559A3A57.3050304@arm.com> <20150706102438.GA2102@arm.com> In-Reply-To: <20150706102438.GA2102@arm.com> X-MC-Unique: uav1QrpiRFOB3mLeMSLQjg-1 X-IsSubscribed: yes On 06/07/15 11:24, James Greenhalgh wrote: > > Please make sure in a follow-up patch that the costing logic in > aarch64_rtx_costs also gets updated. > Tested with aarch64-none-linux-gnu cross compiler. is this OK? i assume i should backport the fnmul fixes to the gcc-5 branch. 2015-07-16 Szabolcs Nagy * config/aarch64/aarch64.c (aarch64_rtx_costs): Fix NEG cost for FNMUL. (aarch64_rtx_mult_cost): Fix MULT cost with -frounding-math. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 6c13a078..1a3d6be 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -5435,11 +5435,17 @@ aarch64_rtx_mult_cost (rtx x, enum rtx_code code, int outer, bool speed) if (speed) { /* Floating-point FMA/FMUL can also support negations of the - operands. */ - if (GET_CODE (op0) == NEG) - op0 = XEXP (op0, 0); - if (GET_CODE (op1) == NEG) - op1 = XEXP (op1, 0); + operands, unless the rounding mode is upward or downward in + which case FNMUL is different than FMUL with operand negation. */ + bool neg0 = GET_CODE (op0) == NEG; + bool neg1 = GET_CODE (op1) == NEG; + if (compound_p || !flag_rounding_math || (neg0 && neg1)) + { + if (neg0) + op0 = XEXP (op0, 0); + if (neg1) + op1 = XEXP (op1, 0); + } if (compound_p) /* FMADD/FNMADD/FNMSUB/FMSUB. */ @@ -5956,6 +5962,12 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED, *cost = rtx_cost (op0, mode, NEG, 0, speed); return true; } + if (GET_CODE (op0) == MULT) + { + /* FNMUL. */ + *cost = rtx_cost (op0, mode, NEG, 0, speed); + return true; + } if (speed) /* FNEG. */ *cost += extra_cost->fp[mode == DFmode].neg;