On Apr 4, 2011, Bernd Schmidt <ber...@codesourcery.com> wrote: > There were a few places where last_scheduled_insn wasn't just examined > on its own, but code wanted to walk backwards and forwards from it. This > patch adapts them. I've also included Steven's patch from the bugzilla.
While debugging the -fcompare-debug regression that turned out to be independently reported as 48403, I got slightly annoyed that rank_for_schedule would walk a sequence of debug insns over and over, once per compare. I figured it might be useful to waste a few bits of static memory to save a pointer to the latest nondebug scheduled insn, so we wouldn't have to skip over debug insns at that point. Regstrapped on x86_64- and i686-linux-gnu. Ok to install?
for gcc/ChangeLog from Alexandre Oliva <aol...@redhat.com> * haifa-sched.c (last_nondebug_scheduled_insn): New. (rank_for_schedule): Use it. (schedule_block): Set it. Index: gcc/haifa-sched.c =================================================================== --- gcc/haifa-sched.c.orig 2011-04-05 05:29:27.910000535 -0300 +++ gcc/haifa-sched.c 2011-04-05 05:40:59.733889664 -0300 @@ -783,6 +783,12 @@ print_curr_reg_pressure (void) /* Pointer to the last instruction scheduled. */ static rtx last_scheduled_insn; +/* Pointer to the last nondebug instruction scheduled within the + block, or the prev_head of the scheduling block. Used by + rank_for_schedule, so that insns independent of the last scheduled + insn will be preferred over dependent instructions. */ +static rtx last_nondebug_scheduled_insn; + /* Pointer that iterates through the list of unscheduled insns if we have a dbg_cnt enabled. It always points at an insn prior to the first unscheduled one. */ @@ -1158,7 +1164,6 @@ rank_for_schedule (const void *x, const { rtx tmp = *(const rtx *) y; rtx tmp2 = *(const rtx *) x; - rtx last; int tmp_class, tmp2_class; int val, priority_val, info_val; @@ -1239,24 +1244,14 @@ rank_for_schedule (const void *x, const if(flag_sched_rank_heuristic && info_val) return info_val; - if (flag_sched_last_insn_heuristic) - { - int i = VEC_length (rtx, scheduled_insns); - last = NULL_RTX; - while (i-- > 0) - { - last = VEC_index (rtx, scheduled_insns, i); - if (NONDEBUG_INSN_P (last)) - break; - } - } - /* Compare insns based on their relation to the last scheduled non-debug insn. */ - if (flag_sched_last_insn_heuristic && last && NONDEBUG_INSN_P (last)) + if (flag_sched_last_insn_heuristic + && NONDEBUG_INSN_P (last_nondebug_scheduled_insn)) { dep_t dep1; dep_t dep2; + rtx last = last_nondebug_scheduled_insn; /* Classify the instructions into three classes: 1) Data dependent on last schedule insn. @@ -2967,6 +2962,7 @@ schedule_block (basic_block *target_bb) /* We start inserting insns after PREV_HEAD. */ last_scheduled_insn = nonscheduled_insns_begin = prev_head; + last_nondebug_scheduled_insn = last_scheduled_insn; gcc_assert ((NOTE_P (last_scheduled_insn) || DEBUG_INSN_P (last_scheduled_insn)) @@ -3226,7 +3222,8 @@ schedule_block (basic_block *target_bb) /* Update counters, etc in the scheduler's front end. */ (*current_sched_info->begin_schedule_ready) (insn); VEC_safe_push (rtx, heap, scheduled_insns, insn); - last_scheduled_insn = insn; + gcc_assert (NONDEBUG_INSN_P (insn)); + last_nondebug_scheduled_insn = last_scheduled_insn = insn; if (recog_memoized (insn) >= 0) {
-- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer