This patch makes the detection of long-running instructions independent of their latency and checks the execution unit instead.
--- gcc/config/s390/s390.c | 73 +++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 95a4460dcf5..15926ec88cd 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -349,12 +349,11 @@ static int last_scheduled_unit_distance[MAX_SCHED_UNITS]; #define NUM_SIDES 2 static int current_side = 1; -#define LONGRUNNING_THRESHOLD 20 /* Estimate of number of cycles a long-running insn occupies an execution unit. */ -static unsigned fxd_longrunning[NUM_SIDES]; -static unsigned fpd_longrunning[NUM_SIDES]; +static int fxd_longrunning[NUM_SIDES]; +static int fpd_longrunning[NUM_SIDES]; /* The maximum score added for an instruction whose unit hasn't been in use for MAX_SCHED_MIX_DISTANCE steps. Increase this value to @@ -14357,6 +14356,17 @@ s390_get_unit_mask (rtx_insn *insn, int *units) return mask; } +/* Returns TRUE if INSN is a long-running instruction. */ +static bool +s390_is_longrunning (rtx_insn *insn) +{ + if (insn == NULL_RTX) + return false; + + return get_attr_z13_unit_fxd (insn) || get_attr_z13_unit_fpd (insn) + || get_attr_z14_unit_fxd (insn) || get_attr_z14_unit_fpd (insn); +} + /* Return the scheduling score for INSN. The higher the score the better. The score is calculated from the OOO scheduling attributes of INSN and the scheduling state s390_sched_state. */ @@ -14432,20 +14442,48 @@ s390_sched_score (rtx_insn *insn) score += (last_scheduled_unit_distance[i] * MAX_SCHED_MIX_SCORE / MAX_SCHED_MIX_DISTANCE); - unsigned latency = insn_default_latency (insn); - int other_side = 1 - current_side; /* Try to delay long-running insns when side is busy. */ - if (latency > LONGRUNNING_THRESHOLD) + if (s390_is_longrunning (insn)) { - if (get_attr_z13_unit_fxu (insn) && fxd_longrunning[current_side] - && fxd_longrunning[other_side] <= fxd_longrunning[current_side]) - score = MAX (0, score - 10); + if (s390_tune == PROCESSOR_2964_Z13) + { + if (get_attr_z13_unit_fxd (insn) && fxd_longrunning[current_side] + && fxd_longrunning[other_side] <= fxd_longrunning[current_side]) + score = MAX (0, score - 10); - if (get_attr_z13_unit_vfu (insn) && fpd_longrunning[current_side] - && fpd_longrunning[other_side] <= fpd_longrunning[current_side]) - score = MAX (0, score - 10); + if (get_attr_z13_unit_fxd (insn) + && fxd_longrunning[other_side] >= fxd_longrunning[current_side]) + score += 10; + + if (get_attr_z13_unit_fpd (insn) && fpd_longrunning[current_side] + && fpd_longrunning[other_side] <= fpd_longrunning[current_side]) + score = MAX (0, score - 10); + + if (get_attr_z13_unit_fpd (insn) + && fpd_longrunning[other_side] >= fpd_longrunning[current_side]) + score += 10; + } + + if (s390_tune == PROCESSOR_3906_Z14) + { + if (get_attr_z14_unit_fxd (insn) && fxd_longrunning[current_side] + && fxd_longrunning[other_side] <= fxd_longrunning[current_side]) + score = MAX (0, score - 10); + + if (get_attr_z14_unit_fxd (insn) + && fxd_longrunning[other_side] >= fxd_longrunning[current_side]) + score += 10; + + if (get_attr_z14_unit_fpd (insn) && fpd_longrunning[current_side] + && fpd_longrunning[other_side] <= fpd_longrunning[current_side]) + score = MAX (0, score - 10); + + if (get_attr_z14_unit_fpd (insn) + && fpd_longrunning[other_side] >= fpd_longrunning[current_side]) + score += 10; + } } } @@ -14629,16 +14667,15 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more) for (int i = 0; i < 2; i++) { - if (fxd_longrunning[i] >= 1) - fxd_longrunning[i] -= 1; - if (fpd_longrunning[i] >= 1) - fpd_longrunning[i] -= 1; + fxd_longrunning[i] = MAX (0, fxd_longrunning[i] - 1); + fpd_longrunning[i] = MAX (0, fpd_longrunning[i] - 1); } unsigned latency = insn_default_latency (insn); - if (latency > LONGRUNNING_THRESHOLD) + if (s390_is_longrunning (insn)) { - if (get_attr_z13_unit_fxu (insn)) + if (get_attr_z13_unit_fxd (insn) + || get_attr_z14_unit_fxd (insn)) fxd_longrunning[current_side] = latency; else fpd_longrunning[current_side] = latency; -- 2.17.0