From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4192 invoked by alias); 30 Jan 2014 05:42:20 -0000 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 Received: (qmail 4099 invoked by uid 89); 30 Jan 2014 05:42:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail.ispras.ru Received: from mail.ispras.ru (HELO mail.ispras.ru) (83.149.199.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jan 2014 05:42:16 +0000 Received: from [10.10.3.52] (pluton2.ispras.ru [83.149.199.44]) by mail.ispras.ru (Postfix) with ESMTPSA id DBDB4540151; Thu, 30 Jan 2014 09:42:13 +0400 (MSK) Message-ID: <52E9E63D.4070405@ispras.ru> Date: Thu, 30 Jan 2014 05:42:00 -0000 From: Andrey Belevantsev User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: GCC Patches CC: "Vladimir N. Makarov" Subject: [PATCH] Fix PR 58960 Content-Type: multipart/mixed; boundary="------------010103030806070601000001" X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg01936.txt.bz2 This is a multi-part message in MIME format. --------------010103030806070601000001 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1184 Hello, As detailed in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58960#c6, we fail to use the DF liveness info in the register pressure sensitive scheduling for the new blocks as we do not properly compute it in this case. The patch fixes this by avoiding to use the sched-pressure for the new regions, as currently these are only ia64 recovery blocks and supposed to be cold. In the case we'd get other cases of the new blocks, this may be reconsidered. The other options of computing the DF info sketched at the above link do not seem plausible for this stage. Bootstrapped and tested on ia64, also tested by Andreas Schwab on ia64 (see PR log). OK for trunk? Andrey 2013-01-30 Andrey Belevantsev PR rtl-optimization/58960 * haifa-sched.c (alloc_global_sched_pressure_data): New, factored out from ... (sched_init) ... here. (free_global_sched_pressure_data): New, factored out from ... (sched_finish): ... here. * sched-int.h (free_global_sched_pressure_data): Declare. * sched-rgn.c (nr_regions_initial): New static global. (haifa_find_rgns): Initialize it. (schedule_region): Disable sched-pressure for the newly generated regions. --------------010103030806070601000001 Content-Type: text/x-patch; name="pr58960.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr58960.diff" Content-length: 5078 diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index 4d51984..45398bf 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -6553,6 +6553,53 @@ setup_sched_dump (void) ? stderr : dump_file); } +/* Allocate data for register pressure sensitive scheduling. */ +static void +alloc_global_sched_pressure_data (void) +{ + if (sched_pressure != SCHED_PRESSURE_NONE) + { + int i, max_regno = max_reg_num (); + + if (sched_dump != NULL) + /* We need info about pseudos for rtl dumps about pseudo + classes and costs. */ + regstat_init_n_sets_and_refs (); + ira_set_pseudo_classes (true, sched_verbose ? sched_dump : NULL); + sched_regno_pressure_class + = (enum reg_class *) xmalloc (max_regno * sizeof (enum reg_class)); + for (i = 0; i < max_regno; i++) + sched_regno_pressure_class[i] + = (i < FIRST_PSEUDO_REGISTER + ? ira_pressure_class_translate[REGNO_REG_CLASS (i)] + : ira_pressure_class_translate[reg_allocno_class (i)]); + curr_reg_live = BITMAP_ALLOC (NULL); + if (sched_pressure == SCHED_PRESSURE_WEIGHTED) + { + saved_reg_live = BITMAP_ALLOC (NULL); + region_ref_regs = BITMAP_ALLOC (NULL); + } + } +} + +/* Free data for register pressure sensitive scheduling. */ +void +free_global_sched_pressure_data (void) +{ + if (sched_pressure != SCHED_PRESSURE_NONE) + { + if (regstat_n_sets_and_refs != NULL) + regstat_free_n_sets_and_refs (); + if (sched_pressure == SCHED_PRESSURE_WEIGHTED) + { + BITMAP_FREE (region_ref_regs); + BITMAP_FREE (saved_reg_live); + } + BITMAP_FREE (curr_reg_live); + free (sched_regno_pressure_class); + } +} + /* Initialize some global state for the scheduler. This function works with the common data shared between all the schedulers. It is called from the scheduler specific initialization routine. */ @@ -6656,29 +6703,7 @@ sched_init (void) if (targetm.sched.init_global) targetm.sched.init_global (sched_dump, sched_verbose, get_max_uid () + 1); - if (sched_pressure != SCHED_PRESSURE_NONE) - { - int i, max_regno = max_reg_num (); - - if (sched_dump != NULL) - /* We need info about pseudos for rtl dumps about pseudo - classes and costs. */ - regstat_init_n_sets_and_refs (); - ira_set_pseudo_classes (true, sched_verbose ? sched_dump : NULL); - sched_regno_pressure_class - = (enum reg_class *) xmalloc (max_regno * sizeof (enum reg_class)); - for (i = 0; i < max_regno; i++) - sched_regno_pressure_class[i] - = (i < FIRST_PSEUDO_REGISTER - ? ira_pressure_class_translate[REGNO_REG_CLASS (i)] - : ira_pressure_class_translate[reg_allocno_class (i)]); - curr_reg_live = BITMAP_ALLOC (NULL); - if (sched_pressure == SCHED_PRESSURE_WEIGHTED) - { - saved_reg_live = BITMAP_ALLOC (NULL); - region_ref_regs = BITMAP_ALLOC (NULL); - } - } + alloc_global_sched_pressure_data (); curr_state = xmalloc (dfa_state_size); } @@ -6777,18 +6802,7 @@ void sched_finish (void) { haifa_finish_h_i_d (); - if (sched_pressure != SCHED_PRESSURE_NONE) - { - if (regstat_n_sets_and_refs != NULL) - regstat_free_n_sets_and_refs (); - if (sched_pressure == SCHED_PRESSURE_WEIGHTED) - { - BITMAP_FREE (region_ref_regs); - BITMAP_FREE (saved_reg_live); - } - BITMAP_FREE (curr_reg_live); - free (sched_regno_pressure_class); - } + free_global_sched_pressure_data (); free (curr_state); if (targetm.sched.finish_global) diff --git a/gcc/sched-int.h b/gcc/sched-int.h index 3b1106f..b5481b9 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -1337,6 +1337,7 @@ extern void debug_ds (ds_t); extern void initialize_live_range_shrinkage (void); extern void finish_live_range_shrinkage (void); extern void sched_init_region_reg_pressure_info (void); +extern void free_global_sched_pressure_data (void); extern int haifa_classify_insn (const_rtx); extern void get_ebb_head_tail (basic_block, basic_block, rtx *, rtx *); extern int no_real_insns_p (const_rtx, const_rtx); diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c index 406dc1f..0573b6a 100644 --- a/gcc/sched-rgn.c +++ b/gcc/sched-rgn.c @@ -79,6 +79,9 @@ static int is_cfg_nonregular (void); /* Number of regions in the procedure. */ int nr_regions = 0; +/* Same as above before adding any new regions. */ +static int nr_regions_initial = 0; + /* Table of region descriptions. */ region *rgn_table = NULL; @@ -1064,6 +1067,7 @@ haifa_find_rgns (void) BLOCK_TO_BB (bb->index) = 0; } + nr_regions_initial = nr_regions; free (max_hdr); free (degree); free (stack); @@ -2991,6 +2995,15 @@ schedule_region (int rgn) rgn_n_insns = 0; + /* Do not support register pressure sensitive scheduling for the new regions + as we don't update the liveness info for them. */ + if (rgn >= nr_regions_initial) + { + if (sched_pressure != SCHED_PRESSURE_NONE) + free_global_sched_pressure_data (); + sched_pressure = SCHED_PRESSURE_NONE; + } + rgn_setup_region (rgn); /* Don't schedule region that is marked by --------------010103030806070601000001--