Maxim Kuvyrkov wrote:

Anyway, this work is for stage 1 or 2 and for now I propose following fix: implement targetm.sched.reorder hook so that it will ensure that if there is an insn from the current block in the ready list, then insn from the other block won't stand first in the line (and, therefore, won't be chosen for schedule). I feel that this will be what you are calling 'filling holes'. Please find an example patch attached (arm.patch).

Do you think this could be a default implementation of the reorder hook,
like this?  (After suitable performance testing.  This looks O(n^2) to me).

--- in defaults.h ---

#ifndef TARGET_SCHED_REORDER
#define TARGET_SCHED_REORDER default_reorder
#endif

#ifndef TARGET_SCHED_REORDER2
#define TARGET_SCHED_REORDER2 default_reorder2
#endif

--- in targhooks.c ---

int
default_reorder (FILE *dump, int sched_verbose,
                 rtx *ready, int *pn_ready, int clock_var)
{
  default_reorder2 (dump, sched_verbose, ready, pn_ready, clock_var);
  if (targetm.sched.issue_rate)
    return targetm.sched.issue_rate ();
  else
    return 1;
}

int
default_reorder2 (FILE *dump ATTRIBUTE_UNUSED,
                  int sched_verbose ATTRIBUTE_UNUSED,
                  rtx *ready, int *pn_ready,
                  int clock_var ATTRIBUTE_UNUSED)
{
  int n_ready = *pn_ready;

  /* This is correct for sched-rgn.c only.  */
  if (reload_completed
      && (flag_sched2_use_superblocks || flag_sched2_use_traces))
    return 0;

  if (n_ready > 1)
    {
      basic_block bb = BLOCK_FOR_INSN (current_sched_info->prev_head);

      if (BLOCK_FOR_INSN (ready[n_ready - 1]) != bb)
        {
          int i;

          for (i = n_ready - 1; i >= 0; i--)
            {
              rtx insn = ready[i];

              if (BLOCK_FOR_INSN (insn) != bb)
                continue;

              memcpy (ready + i, ready + i + 1,
                      (n_ready - i - 1) * sizeof (*ready));
              ready[n_ready - 1] = insn;
              break;
            }
        }
    }

  return 0;
}

Paolo

Reply via email to