From patchwork Sun Aug 3 13:54:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 376017 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 8E9571400A3 for ; Sun, 3 Aug 2014 23:54:47 +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:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=MC6Hh0H02EPnBwX/Cbhm1ANNI0LUX BtHOxEOZTvsjlTIzADZwYi9wtYUq3sHXQAH4yORl0Dd9eCmEKTgzVH79uEHorHx9 CQWCZl5DKDX3igDy1WqATBLM8zK6inHd5JVGZe0sLsyaX8lq6Ffs3C+X6sqC23is JI7pU0vA50qgSA= 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=uO+cnNATWcJaRCgxmwWmTbAW2Cs=; b=iNB YK4C2ztW0wGEd9vQC9ID5uDNjpShc5ErZvTF5GHCfp3q8xwyU3sbyh34lxrRp5Zf YiYfTpuKzZwqu74z4uKjTuE9PMgGjsAmn62paPXmVQJC/XhhYxcZdIkSboys9BhN ZH1Xl0NxMsD7aoDPe59adf5+0zeG7HVQdTpOVd20= Received: (qmail 16920 invoked by alias); 3 Aug 2014 13:54:40 -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 16890 invoked by uid 89); 3 Aug 2014 13:54:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f44.google.com Received: from mail-wg0-f44.google.com (HELO mail-wg0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 03 Aug 2014 13:54:34 +0000 Received: by mail-wg0-f44.google.com with SMTP id m15so6301485wgh.3 for ; Sun, 03 Aug 2014 06:54:31 -0700 (PDT) X-Received: by 10.194.60.240 with SMTP id k16mr24276838wjr.109.1407074070953; Sun, 03 Aug 2014 06:54:30 -0700 (PDT) Received: from localhost ([95.145.138.172]) by mx.google.com with ESMTPSA id yw9sm31209626wjc.31.2014.08.03.06.54.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Aug 2014 06:54:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [PATCH 10/50] cse.c:approx_reg_cost References: <87y4v5d77q.fsf@googlemail.com> Date: Sun, 03 Aug 2014 14:54:30 +0100 In-Reply-To: <87y4v5d77q.fsf@googlemail.com> (Richard Sandiford's message of "Sun, 03 Aug 2014 14:38:01 +0100") Message-ID: <87r40xbrvt.fsf@googlemail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 gcc/ * cse.c: Include rtl-iter.h. (approx_reg_cost_1): Delete. (approx_reg_cost): Use FOR_EACH_SUBRTX instead of for_each_rtx. Don't handle null rtxes. Index: gcc/cse.c =================================================================== --- gcc/cse.c 2014-08-03 11:25:10.373958740 +0100 +++ gcc/cse.c 2014-08-03 11:25:22.876082343 +0100 @@ -42,6 +42,7 @@ Software Foundation; either version 3, o #include "df.h" #include "dbgcnt.h" #include "hash-set.h" +#include "rtl-iter.h" /* The basic idea of common subexpression elimination is to go through the code, keeping a record of expressions that would @@ -550,8 +551,6 @@ struct cse_basic_block_data static bool fixed_base_plus_p (rtx x); static int notreg_cost (rtx, enum rtx_code, int); -static int approx_reg_cost_1 (rtx *, void *); -static int approx_reg_cost (rtx); static int preferable (int, int, int, int); static void new_basic_block (void); static void make_new_qty (unsigned int, enum machine_mode); @@ -660,47 +659,35 @@ dump_class (struct table_elt *classp) } } -/* Subroutine of approx_reg_cost; called through for_each_rtx. */ +/* Return an estimate of the cost of the registers used in an rtx. + This is mostly the number of different REG expressions in the rtx; + however for some exceptions like fixed registers we use a cost of + 0. If any other hard register reference occurs, return MAX_COST. */ static int -approx_reg_cost_1 (rtx *xp, void *data) +approx_reg_cost (const_rtx x) { - rtx x = *xp; - int *cost_p = (int *) data; - - if (x && REG_P (x)) + int cost = 0; + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, x, NONCONST) { - unsigned int regno = REGNO (x); - - if (! CHEAP_REGNO (regno)) + const_rtx x = *iter; + if (REG_P (x)) { - if (regno < FIRST_PSEUDO_REGISTER) + unsigned int regno = REGNO (x); + if (!CHEAP_REGNO (regno)) { - if (targetm.small_register_classes_for_mode_p (GET_MODE (x))) - return 1; - *cost_p += 2; + if (regno < FIRST_PSEUDO_REGISTER) + { + if (targetm.small_register_classes_for_mode_p (GET_MODE (x))) + return MAX_COST; + cost += 2; + } + else + cost += 1; } - else - *cost_p += 1; } } - - return 0; -} - -/* Return an estimate of the cost of the registers used in an rtx. - This is mostly the number of different REG expressions in the rtx; - however for some exceptions like fixed registers we use a cost of - 0. If any other hard register reference occurs, return MAX_COST. */ - -static int -approx_reg_cost (rtx x) -{ - int cost = 0; - - if (for_each_rtx (&x, approx_reg_cost_1, (void *) &cost)) - return MAX_COST; - return cost; }