Avoid exponential runtime

From-SVN: r40145
This commit is contained in:
Bernd Schmidt 2001-03-01 13:21:30 +00:00 committed by Bernd Schmidt
parent c2a3a48235
commit 21e4c9a8db
3 changed files with 33 additions and 17 deletions

View File

@ -1,3 +1,10 @@
2001-03-01 Bernd Schmidt <bernds@redhat.com>
* sched-int.h (struct haifa_insn_data): Add new member priority_known.
(INSN_PRIORITY_KNOWN): New accessor macro.
* haifa-sched.c (priority): Use it instead of testing priority against
zero.
2001-02-28 DJ Delorie <dj@redhat.com>
* config/m68k/m68k.h (MOVE_BY_PIECES_P): Avoid pushing bytes,

View File

@ -719,38 +719,43 @@ static int
priority (insn)
rtx insn;
{
int this_priority;
rtx link;
if (! INSN_P (insn))
return 0;
if ((this_priority = INSN_PRIORITY (insn)) == 0)
if (! INSN_PRIORITY_KNOWN (insn))
{
int this_priority = 0;
if (INSN_DEPEND (insn) == 0)
this_priority = insn_cost (insn, 0, 0);
else
for (link = INSN_DEPEND (insn); link; link = XEXP (link, 1))
{
rtx next;
int next_priority;
{
for (link = INSN_DEPEND (insn); link; link = XEXP (link, 1))
{
rtx next;
int next_priority;
if (RTX_INTEGRATED_P (link))
continue;
if (RTX_INTEGRATED_P (link))
continue;
next = XEXP (link, 0);
next = XEXP (link, 0);
/* Critical path is meaningful in block boundaries only. */
if (! (*current_sched_info->contributes_to_priority) (next, insn))
continue;
/* Critical path is meaningful in block boundaries only. */
if (! (*current_sched_info->contributes_to_priority) (next, insn))
continue;
next_priority = insn_cost (insn, link, next) + priority (next);
if (next_priority > this_priority)
this_priority = next_priority;
}
next_priority = insn_cost (insn, link, next) + priority (next);
if (next_priority > this_priority)
this_priority = next_priority;
}
}
INSN_PRIORITY (insn) = this_priority;
INSN_PRIORITY_KNOWN (insn) = 1;
}
return this_priority;
return INSN_PRIORITY (insn);
}
/* Macros and functions for keeping the priority queue sorted, and

View File

@ -198,6 +198,9 @@ struct haifa_insn_data
moved load insn and this one. */
unsigned int fed_by_spec_load : 1;
unsigned int is_load_insn : 1;
/* Nonzero if priority has been computed already. */
unsigned int priority_known : 1;
};
extern struct haifa_insn_data *h_i_d;
@ -209,6 +212,7 @@ extern struct haifa_insn_data *h_i_d;
#define CANT_MOVE(insn) (h_i_d[INSN_UID (insn)].cant_move)
#define INSN_DEP_COUNT(INSN) (h_i_d[INSN_UID (INSN)].dep_count)
#define INSN_PRIORITY(INSN) (h_i_d[INSN_UID (INSN)].priority)
#define INSN_PRIORITY_KNOWN(INSN) (h_i_d[INSN_UID (INSN)].priority_known)
#define INSN_COST(INSN) (h_i_d[INSN_UID (INSN)].cost)
#define INSN_UNIT(INSN) (h_i_d[INSN_UID (INSN)].units)
#define INSN_REG_WEIGHT(INSN) (h_i_d[INSN_UID (INSN)].reg_weight)