From patchwork Wed May 30 18:15:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 162046 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]) by ozlabs.org (Postfix) with SMTP id 3A656B706F for ; Thu, 31 May 2012 04:16:20 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1339006581; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Mail-Followup-To:Cc:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=B9S9+5DoQMhNM/BeNZia rqAFPbg=; b=sdbypLL1QES3z+fF6HMBj3WzZql0+NfFmkqdFUDvzPZLKBpdwP+0 TlkytDypWE9OQ8Ves6yg2aDXZI1lBTYjQVDkmK3JlTCS2RDohV691JJ3Vwn3t9Xf c4pCSU4mHseCnR9wg63u3LSFdpY76retNlWwY0I3zZ+W3NWnPnRLjeo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Mail-Followup-To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Mrv4QPxjIx5HPI90fMJYpjvc+qRaT3pyRT2BQgm8maLnhbuBZMZmhIk70mO/4t r7OJHFufXArGkkf3yAODspBm3eH2FHkx8KRrPmD5y9zK/b9yXpeoMxy8Zv4dLPCV ZtY9ucvTYWJejE6J6M/ynRm/iBya9CBCNdG8lR62QZdxw=; Received: (qmail 22535 invoked by alias); 30 May 2012 18:16:16 -0000 Received: (qmail 22518 invoked by uid 22791); 30 May 2012 18:16:14 -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 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; Wed, 30 May 2012 18:16:00 +0000 Received: by wgbed3 with SMTP id ed3so82168wgb.8 for ; Wed, 30 May 2012 11:15:58 -0700 (PDT) Received: by 10.216.216.148 with SMTP id g20mr11542021wep.187.1338401758492; Wed, 30 May 2012 11:15:58 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk. [82.133.89.107]) by mx.google.com with ESMTPS id m20sm27478614wie.6.2012.05.30.11.15.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 May 2012 11:15:57 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, vmakarov@redhat.com, rdsandiford@googlemail.com Cc: vmakarov@redhat.com Subject: [1/7] Tidy IRA move costs References: <87d35lh72w.fsf@talisman.home> Date: Wed, 30 May 2012 19:15:56 +0100 In-Reply-To: <87d35lh72w.fsf@talisman.home> (Richard Sandiford's message of "Wed, 30 May 2012 19:11:51 +0100") Message-ID: <878vg9h6w3.fsf@talisman.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 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 For one of the later patches I wanted to test whether a class had any allocatable registers. It turns out that we have two arrays that hold the number of allocatable registers in a class: ira_class_hard_regs_num ira_available_class_regs We calculate them in quick succession and already assert that they're the same: COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl]); AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs); ... for (n = 0, i = 0; i < FIRST_PSEUDO_REGISTER; i++) if (TEST_HARD_REG_BIT (temp_hard_regset, i)) ira_non_ordered_class_hard_regs[cl][n++] = i; ira_assert (ira_class_hard_regs_num[cl] == n); ... COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[i]); AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs); for (j = 0; j < FIRST_PSEUDO_REGISTER; j++) if (TEST_HARD_REG_BIT (temp_hard_regset, j)) ira_available_class_regs[i]++; so this patch removes the latter in favour of the former. Richard gcc/ * ira.h (target_ira): Delete x_ira_available_class_regs. (ira_available_class_regs): Delete. * ira.c (setup_available_class_regs): Delete. (setup_alloc_classes): Don't call it. (setup_pressure_classes): Use ira_class_hard_regs_num instead of ira_available_class_regs. * haifa-sched.c (print_curr_reg_pressure, setup_insn_reg_pressure_info) (model_spill_cost): Likewise. * ira-build.c (low_pressure_loop_node_p): Likewise. * ira-color.c (color_pass): Likewise. * ira-emit.c (change_loop): Likewise. * ira-lives.c (inc_register_pressure, dec_register_pressure) (single_reg_class, ira_implicitly_set_insn_hard_regs) (process_bb_node_lives): Likewise. * loop-invariant.c (gain_for_invariant): Likewise. Index: gcc/ira.h =================================================================== --- gcc/ira.h 2012-05-30 18:57:09.221912963 +0100 +++ gcc/ira.h 2012-05-30 19:08:35.848893000 +0100 @@ -25,10 +25,6 @@ Software Foundation; either version 3, o extern bool ira_conflicts_p; struct target_ira { - /* Number of given class hard registers available for the register - allocation for given classes. */ - int x_ira_available_class_regs[N_REG_CLASSES]; - /* Map: hard register number -> allocno class it belongs to. If the corresponding class is NO_REGS, the hard register is not available for allocation. */ @@ -95,8 +91,6 @@ struct target_ira { #define this_target_ira (&default_target_ira) #endif -#define ira_available_class_regs \ - (this_target_ira->x_ira_available_class_regs) #define ira_hard_regno_allocno_class \ (this_target_ira->x_ira_hard_regno_allocno_class) #define ira_allocno_classes_num \ Index: gcc/ira.c =================================================================== --- gcc/ira.c 2012-05-30 18:57:09.222912964 +0100 +++ gcc/ira.c 2012-05-30 19:08:35.848893000 +0100 @@ -490,23 +490,6 @@ setup_class_hard_regs (void) } } -/* Set up IRA_AVAILABLE_CLASS_REGS. */ -static void -setup_available_class_regs (void) -{ - int i, j; - - memset (ira_available_class_regs, 0, sizeof (ira_available_class_regs)); - for (i = 0; i < N_REG_CLASSES; i++) - { - COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[i]); - AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs); - for (j = 0; j < FIRST_PSEUDO_REGISTER; j++) - if (TEST_HARD_REG_BIT (temp_hard_regset, j)) - ira_available_class_regs[i]++; - } -} - /* Set up global variables defining info about hard registers for the allocation. These depend on USE_HARD_FRAME_P whose TRUE value means that we can use the hard frame pointer for the allocation. */ @@ -520,7 +503,6 @@ setup_alloc_regs (bool use_hard_frame_p) if (! use_hard_frame_p) SET_HARD_REG_BIT (no_unit_alloc_regs, HARD_FRAME_POINTER_REGNUM); setup_class_hard_regs (); - setup_available_class_regs (); } @@ -799,9 +781,9 @@ setup_pressure_classes (void) n = 0; for (cl = 0; cl < N_REG_CLASSES; cl++) { - if (ira_available_class_regs[cl] == 0) + if (ira_class_hard_regs_num[cl] == 0) continue; - if (ira_available_class_regs[cl] != 1 + if (ira_class_hard_regs_num[cl] != 1 /* A register class without subclasses may contain a few hard registers and movement between them is costly (e.g. SPARC FPCC registers). We still should consider it @@ -1504,7 +1486,7 @@ ira_init_register_move_cost (enum machin { /* Some subclasses are to small to have enough registers to hold a value of MODE. Just ignore them. */ - if (ira_reg_class_max_nregs[cl1][mode] > ira_available_class_regs[cl1]) + if (ira_reg_class_max_nregs[cl1][mode] > ira_class_hard_regs_num[cl1]) continue; COPY_HARD_REG_SET (temp_hard_regset, reg_class_contents[cl1]); AND_COMPL_HARD_REG_SET (temp_hard_regset, no_unit_alloc_regs); Index: gcc/haifa-sched.c =================================================================== --- gcc/haifa-sched.c 2012-05-30 18:57:09.221912963 +0100 +++ gcc/haifa-sched.c 2012-05-30 19:08:35.840893001 +0100 @@ -1085,7 +1085,7 @@ print_curr_reg_pressure (void) gcc_assert (curr_reg_pressure[cl] >= 0); fprintf (sched_dump, " %s:%d(%d)", reg_class_names[cl], curr_reg_pressure[cl], - curr_reg_pressure[cl] - ira_available_class_regs[cl]); + curr_reg_pressure[cl] - ira_class_hard_regs_num[cl]); } fprintf (sched_dump, "\n"); } @@ -1634,9 +1634,9 @@ setup_insn_reg_pressure_info (rtx insn) cl = ira_pressure_classes[i]; gcc_assert (curr_reg_pressure[cl] >= 0); change = (int) pressure_info[i].set_increase - death[cl]; - before = MAX (0, max_reg_pressure[i] - ira_available_class_regs[cl]); + before = MAX (0, max_reg_pressure[i] - ira_class_hard_regs_num[cl]); after = MAX (0, max_reg_pressure[i] + change - - ira_available_class_regs[cl]); + - ira_class_hard_regs_num[cl]); hard_regno = ira_class_hard_regs[cl][0]; gcc_assert (hard_regno >= 0); mode = reg_raw_mode[hard_regno]; @@ -2227,7 +2227,7 @@ model_recompute (rtx insn) /* Return the cost of increasing the pressure in class CL from FROM to TO. Here we use the very simplistic cost model that every register above - ira_available_class_regs[CL] has a spill cost of 1. We could use other + ira_class_hard_regs_num[CL] has a spill cost of 1. We could use other measures instead, such as one based on MEMORY_MOVE_COST. However: (1) In order for an instruction to be scheduled, the higher cost @@ -2251,7 +2251,7 @@ model_recompute (rtx insn) static int model_spill_cost (int cl, int from, int to) { - from = MAX (from, ira_available_class_regs[cl]); + from = MAX (from, ira_class_hard_regs_num[cl]); return MAX (to, from) - from; } Index: gcc/ira-build.c =================================================================== --- gcc/ira-build.c 2012-05-30 18:57:09.220912962 +0100 +++ gcc/ira-build.c 2012-05-30 19:08:35.843893000 +0100 @@ -1829,8 +1829,8 @@ low_pressure_loop_node_p (ira_loop_tree_ for (i = 0; i < ira_pressure_classes_num; i++) { pclass = ira_pressure_classes[i]; - if (node->reg_pressure[pclass] > ira_available_class_regs[pclass] - && ira_available_class_regs[pclass] > 1) + if (node->reg_pressure[pclass] > ira_class_hard_regs_num[pclass] + && ira_class_hard_regs_num[pclass] > 1) return false; } return true; Index: gcc/ira-color.c =================================================================== --- gcc/ira-color.c 2012-05-30 18:57:09.220912962 +0100 +++ gcc/ira-color.c 2012-05-30 19:08:35.845893000 +0100 @@ -2766,7 +2766,7 @@ color_pass (ira_loop_tree_node_t loop_tr pclass = ira_pressure_class_translate[rclass]; if (flag_ira_region == IRA_REGION_MIXED && (loop_tree_node->reg_pressure[pclass] - <= ira_available_class_regs[pclass])) + <= ira_class_hard_regs_num[pclass])) { mode = ALLOCNO_MODE (a); hard_regno = ALLOCNO_HARD_REGNO (a); @@ -2819,7 +2819,7 @@ color_pass (ira_loop_tree_node_t loop_tr ALLOCNO_NUM (subloop_allocno))); if ((flag_ira_region == IRA_REGION_MIXED) && (loop_tree_node->reg_pressure[pclass] - <= ira_available_class_regs[pclass])) + <= ira_class_hard_regs_num[pclass])) { if (! ALLOCNO_ASSIGNED_P (subloop_allocno)) { Index: gcc/ira-emit.c =================================================================== --- gcc/ira-emit.c 2012-05-30 18:57:09.220912962 +0100 +++ gcc/ira-emit.c 2012-05-30 19:08:35.846893000 +0100 @@ -606,7 +606,7 @@ change_loop (ira_loop_tree_node_t node) == ALLOCNO_HARD_REGNO (parent_allocno)) && (ALLOCNO_HARD_REGNO (allocno) < 0 || (parent->reg_pressure[pclass] + 1 - <= ira_available_class_regs[pclass]) + <= ira_class_hard_regs_num[pclass]) || TEST_HARD_REG_BIT (ira_prohibited_mode_move_regs [ALLOCNO_MODE (allocno)], ALLOCNO_HARD_REGNO (allocno)) Index: gcc/ira-lives.c =================================================================== --- gcc/ira-lives.c 2012-05-30 18:57:09.220912962 +0100 +++ gcc/ira-lives.c 2012-05-30 19:08:35.847893000 +0100 @@ -192,7 +192,7 @@ inc_register_pressure (enum reg_class pc continue; curr_reg_pressure[cl] += n; if (high_pressure_start_point[cl] < 0 - && (curr_reg_pressure[cl] > ira_available_class_regs[cl])) + && (curr_reg_pressure[cl] > ira_class_hard_regs_num[cl])) high_pressure_start_point[cl] = curr_point; if (curr_bb_node->reg_pressure[cl] < curr_reg_pressure[cl]) curr_bb_node->reg_pressure[cl] = curr_reg_pressure[cl]; @@ -221,7 +221,7 @@ dec_register_pressure (enum reg_class pc curr_reg_pressure[cl] -= nregs; ira_assert (curr_reg_pressure[cl] >= 0); if (high_pressure_start_point[cl] >= 0 - && curr_reg_pressure[cl] <= ira_available_class_regs[cl]) + && curr_reg_pressure[cl] <= ira_class_hard_regs_num[cl]) set_p = true; } if (set_p) @@ -235,7 +235,7 @@ dec_register_pressure (enum reg_class pc if (! ira_reg_pressure_class_p[cl]) continue; if (high_pressure_start_point[cl] >= 0 - && curr_reg_pressure[cl] <= ira_available_class_regs[cl]) + && curr_reg_pressure[cl] <= ira_class_hard_regs_num[cl]) high_pressure_start_point[cl] = -1; } } @@ -851,7 +851,7 @@ single_reg_class (const char *constraint ? GENERAL_REGS : REG_CLASS_FROM_CONSTRAINT (c, constraints)); if ((cl != NO_REGS && next_cl != cl) - || (ira_available_class_regs[next_cl] + || (ira_class_hard_regs_num[next_cl] > ira_reg_class_max_nregs[next_cl][GET_MODE (op)])) return NO_REGS; cl = next_cl; @@ -864,7 +864,7 @@ single_reg_class (const char *constraint recog_data.operand[c - '0'], NULL_RTX); if ((cl != NO_REGS && next_cl != cl) || next_cl == NO_REGS - || (ira_available_class_regs[next_cl] + || (ira_class_hard_regs_num[next_cl] > ira_reg_class_max_nregs[next_cl][GET_MODE (op)])) return NO_REGS; cl = next_cl; @@ -943,8 +943,8 @@ ira_implicitly_set_insn_hard_regs (HARD_ if (cl != NO_REGS /* There is no register pressure problem if all of the regs in this class are fixed. */ - && ira_available_class_regs[cl] != 0 - && (ira_available_class_regs[cl] + && ira_class_hard_regs_num[cl] != 0 + && (ira_class_hard_regs_num[cl] <= ira_reg_class_max_nregs[cl][mode])) IOR_HARD_REG_SET (*set, reg_class_contents[cl]); break; @@ -1170,7 +1170,7 @@ process_bb_node_lives (ira_loop_tree_nod if (curr_bb_node->reg_pressure[cl] < curr_reg_pressure[cl]) curr_bb_node->reg_pressure[cl] = curr_reg_pressure[cl]; ira_assert (curr_reg_pressure[cl] - <= ira_available_class_regs[cl]); + <= ira_class_hard_regs_num[cl]); } } EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi) Index: gcc/loop-invariant.c =================================================================== --- gcc/loop-invariant.c 2012-05-30 18:57:09.221912963 +0100 +++ gcc/loop-invariant.c 2012-05-30 19:08:35.849893000 +0100 @@ -1210,7 +1210,7 @@ gain_for_invariant (struct invariant *in + (int) regs_needed[pressure_class] + LOOP_DATA (curr_loop)->max_reg_pressure[pressure_class] + IRA_LOOP_RESERVED_REGS - > ira_available_class_regs[pressure_class]) + > ira_class_hard_regs_num[pressure_class]) break; } if (i < ira_pressure_classes_num)