Hello,

While fixing PR 58960 I forgot about single-block regions placing the initialization of the new nr_regions_initial variable in the wrong place. Thus for single block regions we ended up with nr_regions = 1 and nr_regions_initial = 0 and effectively turned off sched-pressure immediately. No worries for the usual scheduling path but with the -flive-range-shrinkage we have broke an assert that sched-pressure is in the specific mode.

Fixed by placing the initialization properly at the end of sched_rgn_init and also moving the check for sched_pressure != NONE outside of the if statement in schedule_region as discussed in the PR trail with Jakub.

Bootstrapped and tested on x86-64, ok?

Andrey

gcc/

2014-02-21  Andrey Belevantsev  <a...@ispras.ru>

        PR rtl-optimization/60268
        * sched-rgn.c (haifa_find_rgns): Move the nr_regions_initial init to ...
        (sched_rgn_init) ... here.
        (schedule_region): Check for SCHED_PRESSURE_NONE earlier.

testsuite/

2014-02-21  Andrey Belevantsev  <a...@ispras.ru>

        PR rtl-optimization/60268
        * gcc.c-torture/compile/pr60268.c: New test.
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 0573b6a..dc6fa16 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -1067,7 +1067,6 @@ haifa_find_rgns (void)
 	BLOCK_TO_BB (bb->index) = 0;
       }
 
-  nr_regions_initial = nr_regions;
   free (max_hdr);
   free (degree);
   free (stack);
@@ -2997,10 +2996,10 @@ schedule_region (int rgn)
 
   /* 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
+      && rgn >= nr_regions_initial)
     {
-      if (sched_pressure != SCHED_PRESSURE_NONE)
-	free_global_sched_pressure_data ();
+      free_global_sched_pressure_data ();
       sched_pressure = SCHED_PRESSURE_NONE;
     }
 
@@ -3166,6 +3165,7 @@ sched_rgn_init (bool single_blocks_p)
 
   RGN_BLOCKS (nr_regions) = (RGN_BLOCKS (nr_regions - 1) +
 			     RGN_NR_BLOCKS (nr_regions - 1));
+  nr_regions_initial = nr_regions;
 }
 
 /* Free data structures for region scheduling.  */
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr60268.c b/gcc/testsuite/gcc.c-torture/compile/pr60268.c
new file mode 100644
index 0000000..c3a6f94
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr60268.c
@@ -0,0 +1,6 @@
+/* { dg-options "-flive-range-shrinkage" } */
+void f()
+{
+  int i = 0;
+  void *p = 0;
+}

Reply via email to