From patchwork Wed Jun 24 00:55:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 487896 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 B674514030D for ; Wed, 24 Jun 2015 10:56: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=u9FCyHTF; 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=vaFCTwfiK61No/fpp 3JxZgRTsoLeqbrpk4WMs67VK3NoNPMhl9M3qNUUasHlNd1vh1i02BcANMDFZ939T YGcOz9ujggg3hWGGUPju1U0VfCu6ABOMgW9OMj1PMiPxjb4mOgflYaVmREDXW1sc ydE7L5LLzG8JXuIhPbbu9dmEyQ= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=LUtQAoDI4oWA+WXYda7ueNz tMeg=; b=u9FCyHTFGij92suhOHMpDL0aY1FjeAwQ+5rsKgeEAq/IIOknNozWXjw v2A1P5lHhjWW2nzeXS9qs4rxV+sgWRQ/TioA9694rEQ07yslIU9Nt2EzbLTAhUwG 0FSItRTz2Ov9CVAmMXkiBh3BcJ8SgDqStTG0+MORFf8Tyosvvm9A= Received: (qmail 93144 invoked by alias); 24 Jun 2015 00:55:55 -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 93130 invoked by uid 89); 24 Jun 2015 00:55:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f170.google.com Received: from mail-pd0-f170.google.com (HELO mail-pd0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 24 Jun 2015 00:55:53 +0000 Received: by pdjn11 with SMTP id n11so18232017pdj.0 for ; Tue, 23 Jun 2015 17:55:51 -0700 (PDT) X-Received: by 10.66.190.133 with SMTP id gq5mr64837394pac.112.1435107351664; Tue, 23 Jun 2015 17:55:51 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-155-134.oycza5.sa.bigpond.net.au. [58.160.155.134]) by mx.google.com with ESMTPSA id i10sm24607426pdr.78.2015.06.23.17.55.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2015 17:55:51 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id B862EEA0074; Wed, 24 Jun 2015 10:25:46 +0930 (ACST) Date: Wed, 24 Jun 2015 10:25:46 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Subject: [RS6000 7/7] Address cost Message-ID: <20150624005546.GB1723@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org, David Edelsohn References: <20150624004649.GU1723@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150624004649.GU1723@bubble.grove.modra.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes The rs6000 backend currently uses an address cost of zero. This made sense prior to -mcmodel=medium/large, but medium/large model addresses before splitting are really two insns. So we should cost them one more than other addresses. This patch also adjusts rs6000_rtx_cost to use the new address cost, and puts CONST, HIGH and SYMBOL_REF in their own case since they are handling memory addresses, not MEMs. * config/rs6000/rs6000.c (rs6000_address_cost): New function. (TARGET_ADDRESS_COST): Define as rs6000_address_cost. (rs6000_rtx_costs): Use rs6000_address_cost for MEM. Do not cost CONST, HIGH and SYMBOL_REF as for MEM. Handle LO_SUM. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0218d0f..96c23ca 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1117,6 +1117,7 @@ static tree rs6000_builtin_vectorized_libmass (tree, tree, tree); static void rs6000_emit_set_long_const (rtx, HOST_WIDE_INT); static int rs6000_memory_move_cost (machine_mode, reg_class_t, bool); static bool rs6000_debug_rtx_costs (rtx, machine_mode, int, int, int *, bool); +static int rs6000_address_cost (rtx, machine_mode, addr_space_t, bool); static int rs6000_debug_address_cost (rtx, machine_mode, addr_space_t, bool); static int rs6000_debug_adjust_cost (rtx_insn *, rtx, rtx_insn *, int); @@ -1523,7 +1524,7 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS rs6000_rtx_costs #undef TARGET_ADDRESS_COST -#define TARGET_ADDRESS_COST hook_int_rtx_mode_as_bool_0 +#define TARGET_ADDRESS_COST rs6000_address_cost #undef TARGET_DWARF_REGISTER_SPAN #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span @@ -30720,14 +30721,20 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, - (outer_code == SET ? 1 : 0)); return true; - case CONST: - case HIGH: - case SYMBOL_REF: case MEM: /* When optimizing for size, MEM should be slightly more expensive than generating address, e.g., (plus (reg) (const)). L1 cache latency is about two instructions. */ *total = !speed ? COSTS_N_INSNS (1) + 1 : COSTS_N_INSNS (2); + *total += COSTS_N_INSNS (rs6000_address_cost (XEXP (x, 0), mode, + 0, speed)); + return true; + + case CONST: + case HIGH: + case LO_SUM: + case SYMBOL_REF: + *total = COSTS_N_INSNS (1); return true; case LABEL_REF: @@ -31009,6 +31016,26 @@ rs6000_debug_rtx_costs (rtx x, machine_mode mode, int outer_code, return ret; } +/* Say that before being split, -mcmodel=medium/large UNSPEC_TOCREL + addresses cost one more insn than other addresses. */ + +static int +rs6000_address_cost (rtx x, + machine_mode mode ATTRIBUTE_UNUSED, + addr_space_t as ATTRIBUTE_UNUSED, + bool speed ATTRIBUTE_UNUSED) +{ + if (TARGET_CMODEL == CMODEL_SMALL) + return 0; + + if (GET_CODE (x) == PLUS) + x = XEXP (x, 0); + if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TOCREL) + return 1; + + return 0; +} + /* Debug form of ADDRESS_COST that is selected if -mdebug=cost. */ static int