From patchwork Thu Jun 30 21:51:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 102840 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 5FF2FB6F18 for ; Fri, 1 Jul 2011 07:51:52 +1000 (EST) Received: (qmail 14927 invoked by alias); 30 Jun 2011 21:51:50 -0000 Received: (qmail 14915 invoked by uid 22791); 30 Jun 2011 21:51:49 -0000 X-SWARE-Spam-Status: No, hits=1.7 required=5.0 tests=AWL, BAYES_40, KAM_THEBAT, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from contrabass.post.ru (HELO contrabass.corbina.net) (85.21.78.5) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Jun 2011 21:51:34 +0000 Received: from corbina.ru (violin.corbina.net [195.14.50.30]) by contrabass.corbina.net (Postfix) with ESMTP id 9AD50CB56B for ; Fri, 1 Jul 2011 01:51:32 +0400 (MSD) Received: from [95.24.57.48] (account aesok@post.ru HELO Vista.beeline) by fe1-mc.corbina.ru (CommuniGate Pro SMTP 5.4.0) with ESMTPA id 13012598; Fri, 01 Jul 2011 01:51:32 +0400 Date: Fri, 1 Jul 2011 01:51:38 +0400 From: Anatoly Sokolov Message-ID: <777344864.20110701015138@post.ru> To: gcc-patches CC: aesok Subject: [PATCH] Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro MIME-Version: 1.0 X-IsSubscribed: yes 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 Hello. This patch replaces the use of macro CLASS_MAX_NREGS to reading from ira_reg_class_max_nregs array. The ira_reg_class_max_nregs array is initialized from a macro CLASS_MAX_NREGS. This patch should speed up the compiler, a little. The patch has been bootstrapped on and regression tested on x86_64-unknown-linux-gnu for c. OK to install? * ira.h (target_ira): Change type x_ira_reg_class_max_nregs and x_ira_reg_class_min_nregs arrays to unsigned char. * ira-conflicts.c (process_regs_for_copy): Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro. Change type rclass and aclass vars to reg_class_t. * ira-costs.c (record_reg_classes): Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro. Change type rclass var to reg_class_t. * reload.c (combine_reloads, find_reloads, find_reloads_address_1): Use ira_reg_class_max_nregs array instead of CLASS_MAX_NREGS macro. The ira_reg_class_max_nregs array are using not only the IRA passes as well as in scheduling, loop invariant and now in reload passes. I propose to rename ira_reg_class_max_nregs and ira_reg_class_min_nregs array in reg_class_max_nregs and reg_class_min_nregs, move this declaration from ira.h to hard-reg-set.h and initialization from ira.c to reginfo.c. It will call the CLASS_MAX_NREGS macro only in one place the GCC. What is your opinion about these changes? Anatoly. Index: gcc/ira-conflicts.c =================================================================== --- gcc/ira-conflicts.c (revision 175666) +++ gcc/ira-conflicts.c (working copy) @@ -393,7 +393,7 @@ int allocno_preferenced_hard_regno, cost, index, offset1, offset2; bool only_regs_p; ira_allocno_t a; - enum reg_class rclass, aclass; + reg_class_t rclass, aclass; enum machine_mode mode; ira_copy_t cp; @@ -438,7 +438,7 @@ mode = ALLOCNO_MODE (a); aclass = ALLOCNO_CLASS (a); if (only_regs_p && insn != NULL_RTX - && reg_class_size[rclass] <= (unsigned) CLASS_MAX_NREGS (rclass, mode)) + && reg_class_size[rclass] <= ira_reg_class_max_nregs [rclass][mode]) /* It is already taken into account in ira-costs.c. */ return false; index = ira_class_hard_reg_index[aclass][allocno_preferenced_hard_regno]; Index: gcc/reload.c =================================================================== --- gcc/reload.c (revision 175666) +++ gcc/reload.c (working copy) @@ -1769,9 +1769,9 @@ && rld[i].when_needed != RELOAD_FOR_OUTPUT_ADDRESS && rld[i].when_needed != RELOAD_FOR_OUTADDR_ADDRESS && rld[i].when_needed != RELOAD_OTHER - && (CLASS_MAX_NREGS (rld[i].rclass, rld[i].inmode) - == CLASS_MAX_NREGS (rld[output_reload].rclass, - rld[output_reload].outmode)) + && (ira_reg_class_max_nregs [(int) rld[i].rclass][(int) rld[i].inmode] + == ira_reg_class_max_nregs [(int) rld[output_reload].rclass] + [(int) rld[output_reload].outmode]) && rld[i].inc == 0 && rld[i].reg_rtx == 0 #ifdef SECONDARY_MEMORY_NEEDED @@ -4544,7 +4544,7 @@ > GET_MODE_SIZE (rld[i].inmode))) ? rld[i].outmode : rld[i].inmode; - rld[i].nregs = CLASS_MAX_NREGS (rld[i].rclass, rld[i].mode); + rld[i].nregs = ira_reg_class_max_nregs [rld[i].rclass][rld[i].mode]; } /* Special case a simple move with an input reload and a @@ -5994,8 +5994,8 @@ else { enum reg_class rclass = context_reg_class; - if ((unsigned) CLASS_MAX_NREGS (rclass, GET_MODE (SUBREG_REG (x))) - > reg_class_size[rclass]) + if (ira_reg_class_max_nregs [rclass][GET_MODE (SUBREG_REG (x))] + > reg_class_size[(int) rclass]) { x = find_reloads_subreg_address (x, 0, opnum, ADDR_TYPE (type), Index: gcc/ira.h =================================================================== --- gcc/ira.h (revision 175666) +++ gcc/ira.h (working copy) @@ -68,8 +68,8 @@ /* Maps: register class x machine mode -> maximal/minimal number of hard registers of given class needed to store value of given mode. */ - int x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE]; - int x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE]; + unsigned char x_ira_reg_class_max_nregs[N_REG_CLASSES][MAX_MACHINE_MODE]; + unsigned char x_ira_reg_class_min_nregs[N_REG_CLASSES][MAX_MACHINE_MODE]; /* Array analogous to target hook TARGET_MEMORY_MOVE_COST. */ short x_ira_memory_move_cost[MAX_MACHINE_MODE][N_REG_CLASSES][2]; Index: gcc/ira-costs.c =================================================================== --- gcc/ira-costs.c (revision 175666) +++ gcc/ira-costs.c (working copy) @@ -930,15 +930,15 @@ enum machine_mode mode = GET_MODE (ops[!i]); cost_classes_t cost_classes_ptr = regno_cost_classes[regno]; enum reg_class *cost_classes = cost_classes_ptr->classes; - enum reg_class rclass; + reg_class_t rclass; int nr; for (k = cost_classes_ptr->num - 1; k >= 0; k--) { rclass = cost_classes[k]; if (TEST_HARD_REG_BIT (reg_class_contents[rclass], other_regno) - && (reg_class_size[rclass] - == (unsigned) CLASS_MAX_NREGS (rclass, mode))) + && (reg_class_size[(int) rclass] + == ira_reg_class_max_nregs [(int) rclass][(int) mode])) { if (reg_class_size[rclass] == 1) op_costs[i]->cost[k] = -frequency;