From patchwork Thu Mar 27 17:33:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 334428 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 0F2DA14009B for ; Fri, 28 Mar 2014 04:36:02 +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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=fNsyCj6pgzPARpuT gB58cxdsnxPwuTajG4gu+cxa5yiS6TIpozwu1iQttS/Aooe3M6cpGNv/Vo33uymu 7Ktp7g9D/56oMCFkHQcnoIrV5vnSCXbTKPjbpPcSaM2IN7N+fRFT+ZJ5cM57hyEO lELpnaT1N645Y6FGPT34NwxyDbs= 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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=5gV3ok/0+yD0qGxQJjJCl0 zpSlk=; b=Jkwv05zsmF2NxQjN/UKGO7mCF43RVLvikMtM+6bzODM8MVNtMMA9oG 8l8Y/brTBMjoZJtJLjiHwBV0ZfZXu/PqaA0LWEXFTT8Gb0gpjQLxDk6M5WztpfUo F+ax3Larqd6mL0YhV4hJY4faLxW/PLZJi9hqoxqIVZQFlVmG8pYVc= Received: (qmail 32588 invoked by alias); 27 Mar 2014 17:34:18 -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 32337 invoked by uid 89); 27 Mar 2014 17:34:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 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, 27 Mar 2014 17:34:16 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 27 Mar 2014 17:34:13 +0000 Received: from e106375-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 27 Mar 2014 17:34:28 +0000 From: James Greenhalgh To: gcc-patches@gcc.gnu.org Cc: richard.earnshaw@arm.com, marcus.shawcroft@arm.com, philipp.tomsich@theobroma-systems.com Subject: [AArch64 costs 17/18] Cost for SYMBOL_REF, HIGH and LO_SUM Date: Thu, 27 Mar 2014 17:33:41 +0000 Message-Id: <1395941622-22926-18-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <1395941622-22926-1-git-send-email-james.greenhalgh@arm.com> References: <1395941622-22926-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-MC-Unique: 114032717341312701 X-IsSubscribed: yes Hi, Next, costs for SYMBOL_REF, HIGH and LO_SUM. Tested in series on aarch64-none-elf. OK for Stage-1? Thanks, James --- 2014-03-27 James Greenhalgh * config/aarch64/aarch64.c (aarch64_rtx_costs): Cost SYMBOL_REF, HIGH, LO_SUM. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 7a6255b..8ebb3d0 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -5455,15 +5455,44 @@ cost_plus: return false; /* All arguments need to be in registers. */ } - case HIGH: - if (!CONSTANT_P (XEXP (x, 0))) - *cost += rtx_cost (XEXP (x, 0), HIGH, 0, speed); + case SYMBOL_REF: + + if (aarch64_cmodel == AARCH64_CMODEL_LARGE) + { + /* LDR. */ + if (speed) + *cost += extra_cost->ldst.load; + } + else if (aarch64_cmodel == AARCH64_CMODEL_SMALL + || aarch64_cmodel == AARCH64_CMODEL_SMALL_PIC) + { + /* ADRP, followed by ADD. */ + *cost += COSTS_N_INSNS (1); + if (speed) + *cost += 2 * extra_cost->alu.arith; + } + else if (aarch64_cmodel == AARCH64_CMODEL_TINY + || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC) + { + /* ADR. */ + if (speed) + *cost += extra_cost->alu.arith; + } + + if (flag_pic) + { + /* One extra load instruction, after accessing the GOT. */ + *cost += COSTS_N_INSNS (1); + if (speed) + *cost += extra_cost->ldst.load; + } return true; + case HIGH: case LO_SUM: - if (!CONSTANT_P (XEXP (x, 1))) - *cost += rtx_cost (XEXP (x, 1), LO_SUM, 1, speed); - *cost += rtx_cost (XEXP (x, 0), LO_SUM, 0, speed); + /* ADRP/ADD (immediate). */ + if (speed) + *cost += extra_cost->alu.arith; return true; case ZERO_EXTRACT: