comparison gcc/sel-sched-ir.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Instruction scheduling pass. Selective scheduler and pipeliner. 1 /* Instruction scheduling pass. Selective scheduler and pipeliner.
2 Copyright (C) 2006-2017 Free Software Foundation, Inc. 2 Copyright (C) 2006-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
1835 EXPR_USEFULNESS (from)); 1835 EXPR_USEFULNESS (from));
1836 1836
1837 if (EXPR_PRIORITY (to) < EXPR_PRIORITY (from)) 1837 if (EXPR_PRIORITY (to) < EXPR_PRIORITY (from))
1838 EXPR_PRIORITY (to) = EXPR_PRIORITY (from); 1838 EXPR_PRIORITY (to) = EXPR_PRIORITY (from);
1839 1839
1840 if (EXPR_SCHED_TIMES (to) > EXPR_SCHED_TIMES (from)) 1840 /* We merge sched-times half-way to the larger value to avoid the endless
1841 EXPR_SCHED_TIMES (to) = EXPR_SCHED_TIMES (from); 1841 pipelining of unneeded insns. The average seems to be good compromise
1842 between pipelining opportunities and avoiding extra work. */
1843 if (EXPR_SCHED_TIMES (to) != EXPR_SCHED_TIMES (from))
1844 EXPR_SCHED_TIMES (to) = ((EXPR_SCHED_TIMES (from) + EXPR_SCHED_TIMES (to)
1845 + 1) / 2);
1842 1846
1843 if (EXPR_ORIG_BB_INDEX (to) != EXPR_ORIG_BB_INDEX (from)) 1847 if (EXPR_ORIG_BB_INDEX (to) != EXPR_ORIG_BB_INDEX (from))
1844 EXPR_ORIG_BB_INDEX (to) = 0; 1848 EXPR_ORIG_BB_INDEX (to) = 0;
1845 1849
1846 EXPR_ORIG_SCHED_CYCLE (to) = MIN (EXPR_ORIG_SCHED_CYCLE (to), 1850 EXPR_ORIG_SCHED_CYCLE (to) = MIN (EXPR_ORIG_SCHED_CYCLE (to),
3291 } 3295 }
3292 } 3296 }
3293 3297
3294 /* Note a dependence. */ 3298 /* Note a dependence. */
3295 static void 3299 static void
3296 has_dependence_note_dep (insn_t pro ATTRIBUTE_UNUSED, 3300 has_dependence_note_dep (insn_t pro, ds_t ds ATTRIBUTE_UNUSED)
3297 ds_t ds ATTRIBUTE_UNUSED) 3301 {
3298 { 3302 insn_t real_pro = has_dependence_data.pro;
3299 if (!sched_insns_conditions_mutex_p (has_dependence_data.pro, 3303 insn_t real_con = VINSN_INSN_RTX (has_dependence_data.con);
3300 VINSN_INSN_RTX (has_dependence_data.con))) 3304
3305 /* We do not allow for debug insns to move through others unless they
3306 are at the start of bb. This movement may create bookkeeping copies
3307 that later would not be able to move up, violating the invariant
3308 that a bookkeeping copy should be movable as the original insn.
3309 Detect that here and allow that movement if we allowed it before
3310 in the first place. */
3311 if (DEBUG_INSN_P (real_con) && !DEBUG_INSN_P (real_pro)
3312 && INSN_UID (NEXT_INSN (pro)) == INSN_UID (real_con))
3313 return;
3314
3315 if (!sched_insns_conditions_mutex_p (real_pro, real_con))
3301 { 3316 {
3302 ds_t *dsp = &has_dependence_data.has_dep_p[has_dependence_data.where]; 3317 ds_t *dsp = &has_dependence_data.has_dep_p[has_dependence_data.where];
3303 3318
3304 *dsp = ds_full_merge (ds, *dsp, NULL_RTX, NULL_RTX); 3319 *dsp = ds_full_merge (ds, *dsp, NULL_RTX, NULL_RTX);
3305 } 3320 }
3837 /* Check if there is a unnecessary jump after insn left. */ 3852 /* Check if there is a unnecessary jump after insn left. */
3838 if (bb_has_removable_jump_to_p (xbb, xbb->next_bb) 3853 if (bb_has_removable_jump_to_p (xbb, xbb->next_bb)
3839 && INSN_SCHED_TIMES (BB_END (xbb)) == 0 3854 && INSN_SCHED_TIMES (BB_END (xbb)) == 0
3840 && !IN_CURRENT_FENCE_P (BB_END (xbb))) 3855 && !IN_CURRENT_FENCE_P (BB_END (xbb)))
3841 { 3856 {
3842 if (sel_remove_insn (BB_END (xbb), false, false)) 3857 /* We used to call sel_remove_insn here that can trigger tidy_control_flow
3843 return true; 3858 before we fix up the fallthru edge. Correct that ordering by
3859 explicitly doing the latter before the former. */
3860 clear_expr (INSN_EXPR (BB_END (xbb)));
3844 tidy_fallthru_edge (EDGE_SUCC (xbb, 0)); 3861 tidy_fallthru_edge (EDGE_SUCC (xbb, 0));
3862 if (tidy_control_flow (xbb, false))
3863 return true;
3845 } 3864 }
3846 3865
3847 first = sel_bb_head (xbb); 3866 first = sel_bb_head (xbb);
3848 last = sel_bb_end (xbb); 3867 last = sel_bb_end (xbb);
3849 if (MAY_HAVE_DEBUG_INSNS) 3868 if (MAY_HAVE_DEBUG_INSNS)
3888 recompute_toporder_p 3907 recompute_toporder_p
3889 = sel_redirect_edge_and_branch (EDGE_SUCC (xbb->prev_bb, 0), xbb); 3908 = sel_redirect_edge_and_branch (EDGE_SUCC (xbb->prev_bb, 0), xbb);
3890 3909
3891 gcc_assert (EDGE_SUCC (xbb->prev_bb, 0)->flags & EDGE_FALLTHRU); 3910 gcc_assert (EDGE_SUCC (xbb->prev_bb, 0)->flags & EDGE_FALLTHRU);
3892 3911
3912 /* We could have skipped some debug insns which did not get removed with the block,
3913 and the seqnos could become incorrect. Fix them up here. */
3914 if (MAY_HAVE_DEBUG_INSNS && (sel_bb_head (xbb) != first || sel_bb_end (xbb) != last))
3915 {
3916 if (!sel_bb_empty_p (xbb->prev_bb))
3917 {
3918 int prev_seqno = INSN_SEQNO (sel_bb_end (xbb->prev_bb));
3919 if (prev_seqno > INSN_SEQNO (sel_bb_head (xbb)))
3920 for (insn_t insn = sel_bb_head (xbb); insn != first; insn = NEXT_INSN (insn))
3921 INSN_SEQNO (insn) = prev_seqno + 1;
3922 }
3923 }
3924
3893 /* It can turn out that after removing unused jump, basic block 3925 /* It can turn out that after removing unused jump, basic block
3894 that contained that jump, becomes empty too. In such case 3926 that contained that jump, becomes empty too. In such case
3895 remove it too. */ 3927 remove it too. */
3896 if (sel_bb_empty_p (xbb->prev_bb)) 3928 if (sel_bb_empty_p (xbb->prev_bb))
3897 changed = maybe_tidy_empty_bb (xbb->prev_bb); 3929 changed = maybe_tidy_empty_bb (xbb->prev_bb);