From patchwork Thu Jul 10 07:52:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 368495 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 212DC140127 for ; Thu, 10 Jul 2014 17:53:07 +1000 (EST) 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:content-type; q=dns; s=default; b=uNOa2smxhp6Nd6Bxzsoz+7e1PxrYznysQ6iFqOTind7 ZdrrQzPh6l/SPlc61vATSatTt8qVZyw4db6nnxt95urkEA7qFTpKFjTZ/GZnwtF6 EwrzFoi85JvRT+IjPqNaAT3rJa6ZDxNf9hoJbfoKDLy2K6S9zoxz5AIci9sm6C3M = 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:content-type; s=default; bh=U7Z6wgStpw5UYTj+kjlEppXAe78=; b=hOUXQb79pwhg0+Eqj uK8Ayhv2aB/obta8ltedagqtp3SiBpIcX6CEV9dospi4mH30kI5Zh+9EGKtql6EH qt5U4EwKay3wn4q2F4GBFlKWO7T9d27PHOrhOFb3Zgv34w9ZGkIjsPEw+Jyyun9R jbDA0tgZ/patu9OmlrMLpMW15o= Received: (qmail 18748 invoked by alias); 10 Jul 2014 07:53:01 -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 18731 invoked by uid 89); 10 Jul 2014 07:53:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Jul 2014 07:52:59 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 10 Jul 2014 08:52:56 +0100 Received: from [10.1.208.24] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Jul 2014 08:52:56 +0100 Message-ID: <53BE4657.305@arm.com> Date: Thu, 10 Jul 2014 08:52:55 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw Subject: [PATCH][AArch64] Handle fcvta[su] and frint in RTX cost function X-MC-Unique: 114071008525604601 X-IsSubscribed: yes Hi all, This patch adds rtx costing code for the round-to-integer instructions in AArch64. Some of them are implemented as UNSPECs, so I've added the appropriate case to the big switch that can be expanded upon to handle other unspecs in the future. Tested aarch64-none-elf and bootstrapped on aarch64-none-linux-gnu. Ok for trunk? Thanks, Kyrill 2014-07-10 Kyrylo Tkachov * config/aarch64/aarch64.c (aarch64_frint_unspec_p): New function. (aarch64_rtx_costs): Handle FIX, UNSIGNED_FIX, UNSPEC. commit 32fcdbfebf209ac3fce9af3b891e874feef1bdf7 Author: Kyrylo Tkachov Date: Fri Jul 4 14:49:58 2014 +0100 [AArch64] RTX costs for FIX and UNSIGNED_FIX diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 3aba204..4b34dce 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4841,6 +4841,25 @@ aarch64_rtx_arith_op_extract_p (rtx x, enum machine_mode mode) return false; } +static bool +aarch64_frint_unspec_p (unsigned int u) +{ + switch (u) + { + case UNSPEC_FRINTZ: + case UNSPEC_FRINTP: + case UNSPEC_FRINTM: + case UNSPEC_FRINTA: + case UNSPEC_FRINTN: + case UNSPEC_FRINTX: + case UNSPEC_FRINTI: + return true; + + default: + return false; + } +} + /* Calculate the cost of calculating (if_then_else (OP0) (OP1) (OP2)), storing it in *COST. Result is true if the total cost of the operation has now been calculated. */ @@ -5021,7 +5040,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, default: /* We can't make sense of this, assume default cost. */ *cost = COSTS_N_INSNS (1); - break; + return false; } return false; @@ -5719,6 +5738,29 @@ cost_plus: *cost += extra_cost->fp[mode == DFmode].narrow; return false; + case FIX: + case UNSIGNED_FIX: + x = XEXP (x, 0); + /* Strip the rounding part. They will all be implemented + by the fcvt* family of instructions anyway. */ + if (GET_CODE (x) == UNSPEC) + { + unsigned int uns_code = XINT (x, 1); + + if (uns_code == UNSPEC_FRINTA + || uns_code == UNSPEC_FRINTM + || uns_code == UNSPEC_FRINTN + || uns_code == UNSPEC_FRINTP + || uns_code == UNSPEC_FRINTZ) + x = XVECEXP (x, 0, 0); + } + + if (speed) + *cost += extra_cost->fp[GET_MODE (x) == DFmode].toint; + + *cost += rtx_cost (x, (enum rtx_code) code, 0, speed); + return true; + case ABS: if (GET_MODE_CLASS (mode) == MODE_FLOAT) { @@ -5748,6 +5790,17 @@ cost_plus: } return false; + case UNSPEC: + /* The floating point round to integer frint* instructions. */ + if (aarch64_frint_unspec_p (XINT (x, 1))) + { + if (speed) + *cost += extra_cost->fp[mode == DFmode].roundint; + + return false; + } + break; + case TRUNCATE: /* Decompose muldi3_highpart. */ @@ -5782,13 +5835,14 @@ cost_plus: /* Fall through. */ default: - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, - "\nFailed to cost RTX. Assuming default cost.\n"); - - return true; + break; } - return false; + + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + "\nFailed to cost RTX. Assuming default cost.\n"); + + return true; } /* Wrapper around aarch64_rtx_costs, dumps the partial, or total cost