Skip to content

Commit 4327f0d

Browse files
author
wilco
committed
PR84068, PR83459: Fix sort order of SCHED_PRESSURE_MODEL
The comparison function for SCHED_PRESSURE_MODEL is incorrect. If either instruction is not in target_bb, the ordering is not well defined. Since all instructions outside the target_bb get the highest model_index, all we need to do is sort on model_index. If the model_index is the same we defer to RFS_DEP_COUNT and/or RFS_TIE. gcc/ PR rtl-optimization/84068 PR rtl-optimization/83459 * haifa-sched.c (rank_for_schedule): Fix SCHED_PRESSURE_MODEL sorting. gcc/testsuite PR rtl-optimization/84068 PR rtl-optimization/83459 * gcc.dg/pr84068.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257481 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 0cbf452 commit 4327f0d

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

gcc/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2018-02-08 Wilco Dijkstra <[email protected]>
2+
3+
PR rtl-optimization/84068
4+
PR rtl-optimization/83459
5+
* haifa-sched.c (rank_for_schedule): Fix SCHED_PRESSURE_MODEL sorting.
6+
17
2018-02-08 Aldy Hernandez <[email protected]>
28

39
PR tree-optimization/84224

gcc/haifa-sched.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,12 +2783,11 @@ rank_for_schedule (const void *x, const void *y)
27832783
}
27842784

27852785
/* Prefer instructions that occur earlier in the model schedule. */
2786-
if (sched_pressure == SCHED_PRESSURE_MODEL
2787-
&& INSN_BB (tmp) == target_bb && INSN_BB (tmp2) == target_bb)
2786+
if (sched_pressure == SCHED_PRESSURE_MODEL)
27882787
{
27892788
diff = model_index (tmp) - model_index (tmp2);
2790-
gcc_assert (diff != 0);
2791-
return rfs_result (RFS_PRESSURE_INDEX, diff, tmp, tmp2);
2789+
if (diff != 0)
2790+
return rfs_result (RFS_PRESSURE_INDEX, diff, tmp, tmp2);
27922791
}
27932792

27942793
/* Prefer the insn which has more later insns that depend on it.

gcc/testsuite/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2018-02-08 Wilco Dijkstra <[email protected]>
2+
3+
PR rtl-optimization/84068
4+
PR rtl-optimization/83459
5+
* gcc.dg/pr84068.c: New test.
6+
17
2018-02-08 Richard Biener <[email protected]>
28

39
* g++.dg/vect/slp-pr56812.cc: Allow either basic-block or

gcc/testsuite/gcc.dg/pr84068.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O2 -fno-sched-critical-path-heuristic -fno-sched-rank-heuristic --param=max-sched-extend-regions-iters=5 --param sched-pressure-algorithm=2" } */
3+
4+
#ifdef __SIZEOF_INT128__
5+
typedef __int128 largeint;
6+
#else
7+
typedef long long largeint;
8+
#endif
9+
10+
largeint a;
11+
int b;
12+
13+
largeint
14+
foo (char d, short e, int f)
15+
{
16+
b = __builtin_sub_overflow_p (b, 1, (unsigned long)0);
17+
return a + f;
18+
}

0 commit comments

Comments
 (0)