X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fsel-sched.c;h=43e0d51b80237a227ad02f8960cba6667bbb7026;hb=f95918fdf84e1c13446a31f30c4969cd15aa3802;hp=f11faca740aef7e9823c1764584f0d4a0ae4a479;hpb=1f53e2269d3247490e437af60b03e69cb82c34e3;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index f11faca740a..43e0d51b802 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see #include "rtlhooks-def.h" #include "output.h" #include "emit-rtl.h" +#include "ira.h" #ifdef INSN_SCHEDULING #include "sel-sched-ir.h" @@ -813,18 +814,12 @@ count_occurrences_1 (rtx *cur_rtx, void *arg) { rtx_search_arg_p p = (rtx_search_arg_p) arg; - /* The last param FOR_GCSE is true, because otherwise it performs excessive - substitutions like - r8 = r33 - r16 = r33 - for the last insn it presumes r33 equivalent to r8, so it changes it to - r33. Actually, there's no change, but it spoils debugging. */ - if (exp_equiv_p (*cur_rtx, p->x, 0, true)) - { - /* Bail out if we occupy more than one register. */ - if (REG_P (*cur_rtx) - && HARD_REGISTER_P (*cur_rtx) - && hard_regno_nregs[REGNO(*cur_rtx)][GET_MODE (*cur_rtx)] > 1) + if (REG_P (*cur_rtx) && REGNO (*cur_rtx) == REGNO (p->x)) + { + /* Bail out if mode is different or more than one register is used. */ + if (GET_MODE (*cur_rtx) != GET_MODE (p->x) + || (HARD_REGISTER_P (*cur_rtx) + && hard_regno_nregs[REGNO(*cur_rtx)][GET_MODE (*cur_rtx)] > 1)) { p->n = 0; return 1; @@ -837,7 +832,6 @@ count_occurrences_1 (rtx *cur_rtx, void *arg) } if (GET_CODE (*cur_rtx) == SUBREG - && REG_P (p->x) && (!REG_P (SUBREG_REG (*cur_rtx)) || REGNO (SUBREG_REG (*cur_rtx)) == REGNO (p->x))) { @@ -859,6 +853,7 @@ count_occurrences_equiv (rtx what, rtx where) { struct rtx_search_arg arg; + gcc_assert (REG_P (what)); arg.x = what; arg.n = 0; @@ -1268,7 +1263,7 @@ mark_unavailable_hard_regs (def_t def, struct reg_rename *reg_rename_p, if (!HARD_FRAME_POINTER_IS_FRAME_POINTER) add_to_hard_reg_set (®_rename_p->unavailable_hard_regs, - Pmode, HARD_FRAME_POINTER_IS_FRAME_POINTER); + Pmode, HARD_FRAME_POINTER_REGNUM); } #ifdef STACK_REGS @@ -2119,6 +2114,61 @@ moving_insn_creates_bookkeeping_block_p (insn_t insn, return TRUE; } +/* Return true when the conflict with newly created implicit clobbers + between EXPR and THROUGH_INSN is found because of renaming. */ +static bool +implicit_clobber_conflict_p (insn_t through_insn, expr_t expr) +{ + HARD_REG_SET temp; + rtx insn, reg, rhs, pat; + hard_reg_set_iterator hrsi; + unsigned regno; + bool valid; + + /* Make a new pseudo register. */ + reg = gen_reg_rtx (GET_MODE (EXPR_LHS (expr))); + max_regno = max_reg_num (); + maybe_extend_reg_info_p (); + + /* Validate a change and bail out early. */ + insn = EXPR_INSN_RTX (expr); + validate_change (insn, &SET_DEST (PATTERN (insn)), reg, true); + valid = verify_changes (0); + cancel_changes (0); + if (!valid) + { + if (sched_verbose >= 6) + sel_print ("implicit clobbers failed validation, "); + return true; + } + + /* Make a new insn with it. */ + rhs = copy_rtx (VINSN_RHS (EXPR_VINSN (expr))); + pat = gen_rtx_SET (VOIDmode, reg, rhs); + start_sequence (); + insn = emit_insn (pat); + end_sequence (); + + /* Calculate implicit clobbers. */ + extract_insn (insn); + preprocess_constraints (); + ira_implicitly_set_insn_hard_regs (&temp); + AND_COMPL_HARD_REG_SET (temp, ira_no_alloc_regs); + + /* If any implicit clobber registers intersect with regular ones in + through_insn, we have a dependency and thus bail out. */ + EXECUTE_IF_SET_IN_HARD_REG_SET (temp, 0, regno, hrsi) + { + vinsn_t vi = INSN_VINSN (through_insn); + if (bitmap_bit_p (VINSN_REG_SETS (vi), regno) + || bitmap_bit_p (VINSN_REG_CLOBBERS (vi), regno) + || bitmap_bit_p (VINSN_REG_USES (vi), regno)) + return true; + } + + return false; +} + /* Modifies EXPR so it can be moved through the THROUGH_INSN, performing necessary transformations. Record the type of transformation made in PTRANS_TYPE, when it is not NULL. When INSIDE_INSN_GROUP, @@ -2251,6 +2301,17 @@ moveup_expr (expr_t expr, insn_t through_insn, bool inside_insn_group, if (!enable_schedule_as_rhs_p || !EXPR_SEPARABLE_P (expr)) return MOVEUP_EXPR_NULL; + /* When renaming a hard register to a pseudo before reload, extra + dependencies can occur from the implicit clobbers of the insn. + Filter out such cases here. */ + if (!reload_completed && REG_P (EXPR_LHS (expr)) + && HARD_REGISTER_P (EXPR_LHS (expr)) + && implicit_clobber_conflict_p (through_insn, expr)) + { + if (sched_verbose >= 6) + sel_print ("implicit clobbers conflict detected, "); + return MOVEUP_EXPR_NULL; + } EXPR_TARGET_AVAILABLE (expr) = false; was_target_conflict = true; as_rhs = true; @@ -3573,29 +3634,41 @@ process_use_exprs (av_set_t *av_ptr) return NULL; } -/* Lookup EXPR in VINSN_VEC and return TRUE if found. */ +/* Lookup EXPR in VINSN_VEC and return TRUE if found. Also check patterns from + EXPR's history of changes. */ static bool vinsn_vec_has_expr_p (vinsn_vec_t vinsn_vec, expr_t expr) { - vinsn_t vinsn; + vinsn_t vinsn, expr_vinsn; int n; + unsigned i; - FOR_EACH_VEC_ELT (vinsn_t, vinsn_vec, n, vinsn) - if (VINSN_SEPARABLE_P (vinsn)) - { - if (vinsn_equal_p (vinsn, EXPR_VINSN (expr))) - return true; - } - else - { - /* For non-separable instructions, the blocking insn can have - another pattern due to substitution, and we can't choose - different register as in the above case. Check all registers - being written instead. */ - if (bitmap_intersect_p (VINSN_REG_SETS (vinsn), - VINSN_REG_SETS (EXPR_VINSN (expr)))) - return true; - } + /* Start with checking expr itself and then proceed with all the old forms + of expr taken from its history vector. */ + for (i = 0, expr_vinsn = EXPR_VINSN (expr); + expr_vinsn; + expr_vinsn = (i < VEC_length (expr_history_def, + EXPR_HISTORY_OF_CHANGES (expr)) + ? VEC_index (expr_history_def, + EXPR_HISTORY_OF_CHANGES (expr), + i++)->old_expr_vinsn + : NULL)) + FOR_EACH_VEC_ELT (vinsn_t, vinsn_vec, n, vinsn) + if (VINSN_SEPARABLE_P (vinsn)) + { + if (vinsn_equal_p (vinsn, expr_vinsn)) + return true; + } + else + { + /* For non-separable instructions, the blocking insn can have + another pattern due to substitution, and we can't choose + different register as in the above case. Check all registers + being written instead. */ + if (bitmap_intersect_p (VINSN_REG_SETS (vinsn), + VINSN_REG_SETS (expr_vinsn))) + return true; + } return false; } @@ -5703,8 +5776,8 @@ update_and_record_unavailable_insns (basic_block book_block) || EXPR_TARGET_AVAILABLE (new_expr) != EXPR_TARGET_AVAILABLE (cur_expr)) /* Unfortunately, the below code could be also fired up on - separable insns. - FIXME: add an example of how this could happen. */ + separable insns, e.g. when moving insns through the new + speculation check as in PR 53701. */ vinsn_vec_add (&vec_bookkeeping_blocked_vinsns, cur_expr); }