Message ID | 51237A69.5080508@ispras.ru |
---|---|
State | New |
Headers | show |
On Tue, 19 Feb 2013, Andrey Belevantsev wrote: > Hello, > > As we discussed in the PR, the problem here is that the selective scheduler > does not expect that renaming a hard register to a pseudo would result in > extra dependencies. The dependencies come from implicit clobbers code of > sched-deps.c, so I've made a minimal patch that checks only for that case > using the same function from IRA and avoids it. > > The patch fixes the test case on AIX as reported by David and also bootstraps > and tests fine on x86-64 and ia64, ok for trunk? OK (with "1" changed to "true" in arguments to validate_change as discussed offline), thanks.
On 19.02.2013 17:13, Andrey Belevantsev wrote: > Hello, > > As we discussed in the PR, the problem here is that the selective scheduler > does not expect that renaming a hard register to a pseudo would result in > extra dependencies. The dependencies come from implicit clobbers code of > sched-deps.c, so I've made a minimal patch that checks only for that case > using the same function from IRA and avoids it. > > The patch fixes the test case on AIX as reported by David and also > bootstraps and tests fine on x86-64 and ia64, ok for trunk? > > The second patch is restoring debug printing in the scheduler that was > accidentally broken, possibly by Steven's cleanups (now a pattern is > expected where an insn was previously). I will commit is as obvious > separately. > > Andrey > > 2012-02-19 Andrey Belevantsev <abel@ispras.ru> > > PR middle-end/55889 > > * sel-sched.c: Include ira.h. > (implicit_clobber_conflict_p): New function. > (moveup_expr): Use it. > * Makefile.in (sel-sched.o): Depend on ira.h. > Now backported this to 4.7 and 4.6. Andrey Index: gcc/ChangeLog =================================================================== *** gcc/ChangeLog (revision 197297) --- gcc/ChangeLog (revision 197298) *************** *** 1,6 **** --- 1,18 ---- 2013-04-01 Andrey Belevantsev <abel@ispras.ru> Backport from mainline + 2012-02-19 Andrey Belevantsev <abel@ispras.ru> + + PR middle-end/55889 + + * sel-sched.c: Include ira.h. + (implicit_clobber_conflict_p): New function. + (moveup_expr): Use it. + * Makefile.in (sel-sched.o): Depend on ira.h. + + 2013-04-01 Andrey Belevantsev <abel@ispras.ru> + + Backport from mainline 2013-02-25 Andrey Belevantsev <abel@ispras.ru> Alexander Monakov <amonakov@ispras.ru> Index: gcc/sel-sched.c =================================================================== *** gcc/sel-sched.c (revision 197297) --- gcc/sel-sched.c (revision 197298) *************** along with GCC; see the file COPYING3. *** 45,50 **** --- 45,51 ---- #include "rtlhooks-def.h" #include "output.h" #include "emit-rtl.h" + #include "ira.h" #ifdef INSN_SCHEDULING #include "sel-sched-ir.h" *************** moving_insn_creates_bookkeeping_block_p *** 2113,2118 **** --- 2114,2174 ---- 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, *************** moveup_expr (expr_t expr, insn_t through *** 2245,2250 **** --- 2301,2317 ---- 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; Index: gcc/Makefile.in =================================================================== *** gcc/Makefile.in (revision 197297) --- gcc/Makefile.in (revision 197298) *************** sel-sched.o : sel-sched.c $(CONFIG_H) $( *** 3366,3372 **** $(FUNCTION_H) $(INSN_ATTR_H) $(RECOG_H) $(EXCEPT_H) $(PARAMS_H) \ $(TM_P_H) output.h $(TARGET_H) $(TIMEVAR_H) $(TREE_PASS_H) \ $(SCHED_INT_H) $(GGC_H) $(TREE_H) langhooks.h rtlhooks-def.h \ ! $(SEL_SCHED_IR_H) $(SEL_SCHED_DUMP_H) sel-sched.h $(DBGCNT_H) $(EMIT_RTL_H) sel-sched-dump.o : sel-sched-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(RTL_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \ $(FUNCTION_H) $(INSN_ATTR_H) $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(EXCEPT_H) $(PARAMS_H) \ --- 3366,3372 ---- $(FUNCTION_H) $(INSN_ATTR_H) $(RECOG_H) $(EXCEPT_H) $(PARAMS_H) \ $(TM_P_H) output.h $(TARGET_H) $(TIMEVAR_H) $(TREE_PASS_H) \ $(SCHED_INT_H) $(GGC_H) $(TREE_H) langhooks.h rtlhooks-def.h \ ! $(SEL_SCHED_IR_H) $(SEL_SCHED_DUMP_H) sel-sched.h $(DBGCNT_H) $(EMIT_RTL_H) ira.h sel-sched-dump.o : sel-sched-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(RTL_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \ $(FUNCTION_H) $(INSN_ATTR_H) $(DIAGNOSTIC_CORE_H) $(RECOG_H) $(EXCEPT_H) $(PARAMS_H) \
diff --git a/gcc/sel-sched-dump.c b/gcc/sel-sched-dump.c index 4b2be37..0dafe49 100644 --- a/gcc/sel-sched-dump.c +++ b/gcc/sel-sched-dump.c @@ -91,7 +91,7 @@ restore_dump (void) /* Functions for dumping instructions, av sets, and exprs. */ /* Default flags for dumping insns. */ -static int dump_insn_rtx_flags = DUMP_INSN_RTX_PATTERN; +static int dump_insn_rtx_flags = DUMP_INSN_RTX_UID | DUMP_INSN_RTX_PATTERN; /* Default flags for dumping vinsns. */ static int dump_vinsn_flags = (DUMP_VINSN_INSN_RTX | DUMP_VINSN_TYPE @@ -136,7 +136,7 @@ dump_insn_rtx_1 (rtx insn, int flags) sel_print ("%d;", INSN_UID (insn)); if (flags & DUMP_INSN_RTX_PATTERN) - sel_print ("%s;", str_pattern_slim (insn)); + sel_print ("%s;", str_pattern_slim (PATTERN (insn))); if (flags & DUMP_INSN_RTX_BBN) {