]> gcc.gnu.org Git - gcc.git/commitdiff
Avoid exponential runtime
authorBernd Schmidt <bernds@redhat.com>
Thu, 1 Mar 2001 13:21:30 +0000 (13:21 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Thu, 1 Mar 2001 13:21:30 +0000 (13:21 +0000)
From-SVN: r40145

gcc/ChangeLog
gcc/haifa-sched.c
gcc/sched-int.h

index a14925e4d095509052bd167661275c7965a504ea..40a88ef46be667d5b39715a5305519b685aaddec 100644 (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,
index b4053b5e90cd76743a11099352195f2e0bd27e9e..977b6ecd29738891f057a42d771d3036750ff37f 100644 (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);
 }
 \f
 /* Macros and functions for keeping the priority queue sorted, and
index 2a7eb6a03845166ba711ac6be613856376fda0e3..0eb2e6682797cfb115dcc2ad9c97a7ce6877000b 100644 (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)
This page took 0.083688 seconds and 5 git commands to generate.