[PATCH 5/7] S/390: Add side to schedule-mix calculations.

Robin Dapp rdapp@linux.ibm.com
Mon Mar 11 13:13:00 GMT 2019


This patch makes the scheduling score execution-side aware.

---
 gcc/config/s390/s390.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 249df00268a..4dcf1be4445 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -344,11 +344,11 @@ extern int reload_completed;
 
 /* Kept up to date using the SCHED_VARIABLE_ISSUE hook.  */
 static rtx_insn *last_scheduled_insn;
-#define MAX_SCHED_UNITS 4
-static int last_scheduled_unit_distance[MAX_SCHED_UNITS];
-
 #define NUM_SIDES 2
 
+#define MAX_SCHED_UNITS 4
+static int last_scheduled_unit_distance[MAX_SCHED_UNITS][NUM_SIDES];
+
 /* Estimate of number of cycles a long-running insn occupies an
    execution unit.  */
 static int fxd_longrunning[NUM_SIDES];
@@ -14421,8 +14421,8 @@ s390_sched_score (rtx_insn *insn)
 	 CPU.  */
       for (i = 0; i < units; i++, m <<= 1)
 	if (m & unit_mask)
-	  score += (last_scheduled_unit_distance[i] * MAX_SCHED_MIX_SCORE /
-		    MAX_SCHED_MIX_DISTANCE);
+	  score += (last_scheduled_unit_distance[i][sched_state.side]
+	      * MAX_SCHED_MIX_SCORE / MAX_SCHED_MIX_DISTANCE);
 
       int other_side = 1 - sched_state.side;
 
@@ -14622,9 +14622,10 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more)
 
 	  for (i = 0; i < units; i++, m <<= 1)
 	    if (m & unit_mask)
-	      last_scheduled_unit_distance[i] = 0;
-	    else if (last_scheduled_unit_distance[i] < MAX_SCHED_MIX_DISTANCE)
-	      last_scheduled_unit_distance[i]++;
+	      last_scheduled_unit_distance[i][sched_state.side] = 0;
+	    else if (last_scheduled_unit_distance[i][sched_state.side]
+		< MAX_SCHED_MIX_DISTANCE)
+	      last_scheduled_unit_distance[i][sched_state.side]++;
 	}
 
       if ((mask & S390_SCHED_ATTR_MASK_CRACKED) != 0
@@ -14686,9 +14687,10 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more)
 
 	      s390_get_unit_mask (insn, &units);
 
-	      fprintf (file, ";;\t\tBACKEND: units unused for: ");
+	      fprintf (file, ";;\t\tBACKEND: units on this side unused for: ");
 	      for (j = 0; j < units; j++)
-		fprintf (file, "%d:%d ", j, last_scheduled_unit_distance[j]);
+		fprintf (file, "%d:%d ", j,
+		    last_scheduled_unit_distance[j][sched_state.side]);
 	      fprintf (file, "\n");
 	    }
 	}
@@ -14713,9 +14715,6 @@ s390_sched_init (FILE *file ATTRIBUTE_UNUSED,
 		 int verbose ATTRIBUTE_UNUSED,
 		 int max_ready ATTRIBUTE_UNUSED)
 {
-  last_scheduled_insn = NULL;
-  memset (last_scheduled_unit_distance, 0, MAX_SCHED_UNITS * sizeof (int));
-
   /* If the next basic block is most likely entered via a fallthru edge
      we keep the last sched state.  Otherwise we start a new group.
      The scheduler traverses basic blocks in "instruction stream" ordering
@@ -14729,7 +14728,12 @@ s390_sched_init (FILE *file ATTRIBUTE_UNUSED,
     ? NEXT_INSN (current_sched_info->prev_head) : NULL;
   basic_block bb = insn ? BLOCK_FOR_INSN (insn) : NULL;
   if (s390_tune < PROCESSOR_2964_Z13 || !s390_bb_fallthru_entry_likely (bb))
-    sched_state.group_state = 0;
+    {
+      last_scheduled_insn = NULL;
+      memset (last_scheduled_unit_distance, 0,
+	  MAX_SCHED_UNITS * NUM_SIDES * sizeof (int));
+      sched_state.group_state = 0;
+    }
 }
 
 /* This target hook implementation for TARGET_LOOP_UNROLL_ADJUST calculates
-- 
2.17.0



More information about the Gcc-patches mailing list