From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15410 invoked by alias); 6 May 2012 18:55:56 -0000 Received: (qmail 15402 invoked by uid 22791); 6 May 2012 18:55:55 -0000 X-SWARE-Spam-Status: No, hits=-4.1 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_TX X-Spam-Check-By: sourceware.org Received: from mail-wg0-f51.google.com (HELO mail-wg0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 May 2012 18:55:42 +0000 Received: by wgbed3 with SMTP id ed3so3554203wgb.8 for ; Sun, 06 May 2012 11:55:41 -0700 (PDT) Received: by 10.180.80.104 with SMTP id q8mr29035164wix.14.1336330541389; Sun, 06 May 2012 11:55:41 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk. [82.133.89.107]) by mx.google.com with ESMTPS id fo7sm14748191wib.9.2012.05.06.11.55.39 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 May 2012 11:55:40 -0700 (PDT) From: Richard Sandiford To: Georg-Johann Lay Mail-Followup-To: Georg-Johann Lay ,Mike Stump , gcc-patches , Ian Lance Taylor , Kenneth Zadeck , Kenneth Zadeck , ramana.radhakrishnan@linaro.org, rdsandiford@googlemail.com Cc: Mike Stump , gcc-patches , Ian Lance Taylor , Kenneth Zadeck , Kenneth Zadeck , ramana.radhakrishnan@linaro.org Subject: [committed] Fix lower-subreg cost calculation References: <4F67D595.9030700@naturalbridge.com> <4F6881EA.9080306@naturalbridge.com> <4F6889CC.8080302@naturalbridge.com> <4F74CFB3.5090308@naturalbridge.com> <4F75D041.4070206@naturalbridge.com> <4F772EF0.8080509@naturalbridge.com> <4F7B183A.8090903@naturalbridge.com> <87r4w4y647.fsf@talisman.home> <4FA2E181.3010302@gjlay.de> <4FA45FB2.8060307@gjlay.de> Date: Sun, 06 May 2012 18:55:00 -0000 In-Reply-To: <4FA45FB2.8060307@gjlay.de> (Georg-Johann Lay's message of "Sat, 05 May 2012 01:01:06 +0200") Message-ID: <87r4uxdtqr.fsf_-_@talisman.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg00423.txt.bz2 Georg-Johann Lay writes: > TARGET_RTX_COSTS gets called with x = (const_int 1) and outer = SET > for example. How do I get SET_DEST from that information? > > I don't now if lower-subreg.s ever emits such cost requests, but several > passes definitely do. Gah! I really should have remembered that insn_rtx_cost happily ignores both SETs and SET_DESTs, and skips straight to the SET_SRC. This caught me out when looking at the auto-inc-dec rewrite last year too. (The problem in that case was that insn_rtx_cost ignored the cost of MEMs in stores, and only took into account the cost of MEMs in loads.) While that probably ought to change, I felt like I was going down a rathole last time I looked at it, so this patch does what I should have done originally. For the record: I wondered whether rtlanal.c should base the default register-to-register copy cost for mode M on the lowest move_cost[M][c][c]. The problem is that move_cost has traditionally been used to choose between difference classes in the same mode, rather than between modes, with 2 as the base cost. So I don't think it's suitable. Tested on x86_64-linux-gnu and with the upcoming MIPS costs. Installed. Sorry for the breakage. Richard gcc/ * lower-subreg.c (shift_cost): Use set_src_cost, avoiding the SET. (compute_costs): Likewise for the zero extension. Use set_rtx_cost to compute the cost of moves. Set the mode of the target register. Index: gcc/lower-subreg.c =================================================================== --- gcc/lower-subreg.c 2012-05-06 13:47:49.000000000 +0100 +++ gcc/lower-subreg.c 2012-05-06 14:56:47.851024108 +0100 @@ -135,13 +135,11 @@ struct cost_rtxes { shift_cost (bool speed_p, struct cost_rtxes *rtxes, enum rtx_code code, enum machine_mode mode, int op1) { - PUT_MODE (rtxes->target, mode); PUT_CODE (rtxes->shift, code); PUT_MODE (rtxes->shift, mode); PUT_MODE (rtxes->source, mode); XEXP (rtxes->shift, 1) = GEN_INT (op1); - SET_SRC (rtxes->set) = rtxes->shift; - return insn_rtx_cost (rtxes->set, speed_p); + return set_src_cost (rtxes->shift, speed_p); } /* For each X in the range [0, BITS_PER_WORD), set SPLITTING[X] @@ -189,11 +187,12 @@ compute_costs (bool speed_p, struct cost unsigned int i; int word_move_zero_cost, word_move_cost; + PUT_MODE (rtxes->target, word_mode); SET_SRC (rtxes->set) = CONST0_RTX (word_mode); - word_move_zero_cost = insn_rtx_cost (rtxes->set, speed_p); + word_move_zero_cost = set_rtx_cost (rtxes->set, speed_p); SET_SRC (rtxes->set) = rtxes->source; - word_move_cost = insn_rtx_cost (rtxes->set, speed_p); + word_move_cost = set_rtx_cost (rtxes->set, speed_p); if (LOG_COSTS) fprintf (stderr, "%s move: from zero cost %d, from reg cost %d\n", @@ -209,7 +208,7 @@ compute_costs (bool speed_p, struct cost PUT_MODE (rtxes->target, mode); PUT_MODE (rtxes->source, mode); - mode_move_cost = insn_rtx_cost (rtxes->set, speed_p); + mode_move_cost = set_rtx_cost (rtxes->set, speed_p); if (LOG_COSTS) fprintf (stderr, "%s move: original cost %d, split cost %d * %d\n", @@ -236,10 +235,8 @@ compute_costs (bool speed_p, struct cost /* The only case here to check to see if moving the upper part with a zero is cheaper than doing the zext itself. */ - PUT_MODE (rtxes->target, twice_word_mode); PUT_MODE (rtxes->source, word_mode); - SET_SRC (rtxes->set) = rtxes->zext; - zext_cost = insn_rtx_cost (rtxes->set, speed_p); + zext_cost = set_src_cost (rtxes->zext, speed_p); if (LOG_COSTS) fprintf (stderr, "%s %s: original cost %d, split cost %d + %d\n",