loop.h (struct loop_movables): New.
authorMichael Hayes <mhayes@redhat.com>
Mon, 1 Jan 2001 00:03:17 +0000 (00:03 +0000)
committerMichael Hayes <m.hayes@gcc.gnu.org>
Mon, 1 Jan 2001 00:03:17 +0000 (00:03 +0000)
* loop.h (struct loop_movables): New.
(LOOP_MOVABLES): New.
(struct loop_info): Add movables field.
* loop.c (struct movables): Delete.  Replace all uses
with struct loop_movables.
(the_movables): Delete.  Replace all uses with movables
field in loop_info.
(loop_movables_add, loop_movables_free): New functions.
(scan_loop): Use xmalloc instead of alloca for movables.
Call loop_movables_free.

From-SVN: r38573

gcc/ChangeLog
gcc/loop.c
gcc/loop.h

index 33ac6b085c07681c551647ab5ffaca14d9c6d35a..c93980c83e5f46b211ae3a56b2c890d69da0f6a6 100644 (file)
@@ -1,5 +1,18 @@
 2001-01-01  Michael Hayes  <mhayes@redhat.com>
 
+       * loop.h (struct loop_movables): New.
+       (LOOP_MOVABLES): New.
+       (struct loop_info): Add movables field.
+       * loop.c (struct movables): Delete.  Replace all uses
+       with struct loop_movables.
+       (the_movables): Delete.  Replace all uses with movables
+       field in loop_info.
+       (loop_movables_add, loop_movables_free): New functions.
+       (scan_loop): Use xmalloc instead of alloca for movables.
+       Call loop_movables_free.
+       
+2001-01-01  Michael Hayes  <mhayes@redhat.com> 
+
        * loop.c (debug_loops): New.
 
 2000-12-31  Philip Blundell  <philb@gnu.org>
index 50079b1577d109c35c7dd2d09de4668a69c10440..dc917610a568328d06da66a54d03cc9908410631 100644 (file)
@@ -132,17 +132,6 @@ struct movable
   struct movable *next;
 };
 
-struct movables
-{
-  /* Head of movable chain.  */
-  struct movable *head;
-  /* Last movable in chain.  */
-  struct movable *last;
-  /* Number of movables in the loop.  */
-  int num;
-};
-
-static struct movables the_movables;
 
 FILE *loop_dump_stream;
 
@@ -170,15 +159,19 @@ static void replace_call_address PARAMS ((rtx, rtx, rtx));
 #endif
 static rtx skip_consec_insns PARAMS ((rtx, int));
 static int libcall_benefit PARAMS ((rtx));
-static void ignore_some_movables PARAMS ((struct movables *));
-static void force_movables PARAMS ((struct movables *));
-static void combine_movables PARAMS ((struct movables *, struct loop_regs *));
-static int regs_match_p PARAMS ((rtx, rtx, struct movables *));
-static int rtx_equal_for_loop_p PARAMS ((rtx, rtx, struct movables *,
+static void ignore_some_movables PARAMS ((struct loop_movables *));
+static void force_movables PARAMS ((struct loop_movables *));
+static void combine_movables PARAMS ((struct loop_movables *,
+                                     struct loop_regs *));
+static int regs_match_p PARAMS ((rtx, rtx, struct loop_movables *));
+static int rtx_equal_for_loop_p PARAMS ((rtx, rtx, struct loop_movables *,
                                         struct loop_regs *));
 static void add_label_notes PARAMS ((rtx, rtx));
-static void move_movables PARAMS ((struct loop *loop, struct movables *,
+static void move_movables PARAMS ((struct loop *loop, struct loop_movables *,
                                   int, int));
+static void loop_movables_add PARAMS((struct loop_movables *,
+                                     struct movable *));
+static void loop_movables_free PARAMS((struct loop_movables *));
 static int count_nonfixed_reads PARAMS ((const struct loop *, rtx));
 static void strength_reduce PARAMS ((struct loop *, int, int));
 static void find_single_use_in_loop PARAMS ((rtx, rtx, varray_type));
@@ -517,7 +510,7 @@ scan_loop (loop, flags)
   /* The SET from an insn, if it is the only SET in the insn.  */
   rtx set, set1;
   /* Chain describing insns movable in current loop.  */
-  struct movables *movables = &the_movables;
+  struct loop_movables *movables = LOOP_MOVABLES (loop);
   /* Ratio of extra register life span we can justify
      for saving an instruction.  More if loop doesn't call subroutines
      since in that case saving an insn makes more difference
@@ -809,7 +802,7 @@ scan_loop (loop, flags)
                  continue;
                }
 
-             m = (struct movable *) alloca (sizeof (struct movable));
+             m = (struct movable *) xmalloc (sizeof (struct movable));
              m->next = 0;
              m->insn = p;
              m->set_src = src;
@@ -841,11 +834,7 @@ scan_loop (loop, flags)
                m->savings += libcall_benefit (p);
              VARRAY_INT (regs->set_in_loop, regno) = move_insn ? -2 : -1;
              /* Add M to the end of the chain MOVABLES.  */
-             if (movables->head == 0)
-               movables->head = m;
-             else
-               movables->last->next = m;
-             movables->last = m;
+             loop_movables_add (movables, m);
 
              if (m->consec > 0)
                {
@@ -950,11 +939,7 @@ scan_loop (loop, flags)
                  m->savings = 1;
                  VARRAY_INT (regs->set_in_loop, regno) = -1;
                  /* Add M to the end of the chain MOVABLES.  */
-                 if (movables->head == 0)
-                   movables->head = m;
-                 else
-                   movables->last->next = m;
-                 movables->last = m;
+                 loop_movables_add (movables, m);
                }
            }
        }
@@ -1057,6 +1042,10 @@ scan_loop (loop, flags)
        delete_insn (update_end);
     }
 
+
+  /* The movable information is required for strength reduction.  */
+  loop_movables_free (movables);
+
   VARRAY_FREE (regs->single_usage);
   VARRAY_FREE (regs->set_in_loop);
   VARRAY_FREE (regs->n_times_set);
@@ -1256,7 +1245,7 @@ skip_consec_insns (insn, count)
 
 static void
 ignore_some_movables (movables)
-     struct movables *movables;
+     struct loop_movables *movables;
 {
   register struct movable *m, *m1;
 
@@ -1288,7 +1277,7 @@ ignore_some_movables (movables)
 
 static void
 force_movables (movables)
-     struct movables *movables;
+     struct loop_movables *movables;
 {
   register struct movable *m, *m1;
   for (m1 = movables->head; m1; m1 = m1->next)
@@ -1327,7 +1316,7 @@ force_movables (movables)
 
 static void
 combine_movables (movables, regs)
-     struct movables *movables;
+     struct loop_movables *movables;
      struct loop_regs *regs;
 {
   register struct movable *m;
@@ -1447,7 +1436,7 @@ combine_movables (movables, regs)
 static int
 regs_match_p (x, y, movables)
      rtx x, y;
-     struct movables *movables;
+     struct loop_movables *movables;
 {
   unsigned int xn = REGNO (x);
   unsigned int yn = REGNO (y);
@@ -1476,7 +1465,7 @@ regs_match_p (x, y, movables)
 static int
 rtx_equal_for_loop_p (x, y, movables, regs)
      rtx x, y;
-     struct movables *movables;
+     struct loop_movables *movables;
      struct loop_regs *regs;
 {
   register int i;
@@ -1633,7 +1622,7 @@ add_label_notes (x, insns)
 static void
 move_movables (loop, movables, threshold, insn_count)
      struct loop *loop;
-     struct movables *movables;
+     struct loop_movables *movables;
      int threshold;
      int insn_count;
 {
@@ -2136,6 +2125,34 @@ move_movables (loop, movables, threshold, insn_count)
   free (reg_map);
   free (already_moved);
 }
+
+
+static void
+loop_movables_add (movables, m)
+     struct loop_movables *movables;
+     struct movable *m;
+{
+  if (movables->head == 0)
+    movables->head = m;
+  else
+    movables->last->next = m;
+  movables->last = m;
+}
+
+
+static void
+loop_movables_free (movables)
+     struct loop_movables *movables;
+{
+  struct movable *m;
+  struct movable *m_next;
+
+  for (m = movables->head; m; m = m_next)
+    {
+      m_next = m->next;
+      free (m);
+    }
+}  
 \f
 #if 0
 /* Scan X and replace the address of any MEM in it with ADDR.
@@ -6020,8 +6037,9 @@ simplify_giv_expr (loop, x, ext_val, benefit)
          if (loop_invariant_p (loop, x) == 1)
            {
              struct movable *m;
+             struct loop_movables *movables = LOOP_MOVABLES (loop);
 
-             for (m = the_movables.head; m; m = m->next)
+             for (m = movables->head; m; m = m->next)
                if (rtx_equal_p (x, m->set_dest))
                  {
                    /* Ok, we found a match.  Substitute and simplify.  */
@@ -7317,7 +7335,7 @@ check_dbra_loop (loop, insn_count)
           && ! loop_info->has_volatile
           && reversible_mem_store
           && (bl->giv_count + bl->biv_count + loop_info->num_mem_sets
-              + the_movables.num + compare_and_branch == insn_count)
+              + LOOP_MOVABLES (loop)->num + compare_and_branch == insn_count)
           && (bl == ivs->loop_iv_list && bl->next == 0))
          || no_use_except_counting)
        {
index a1aaf82e099d29461fceb57a63e86b00423fea70..441d3a5b58dafee8c51426c330fd0511b6608477 100644 (file)
@@ -28,6 +28,9 @@ Boston, MA 02111-1307, USA.  */
 /* Get the loop info pointer of a loop.  */
 #define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux)
 
+/* Get a pointer to the loop movables structure.  */
+#define LOOP_MOVABLES(LOOP) (&LOOP_INFO (loop)->movables)
+
 /* Get a pointer to the loop registers structure.  */
 #define LOOP_REGS(LOOP) (&LOOP_INFO (loop)->regs)
 
@@ -236,12 +239,28 @@ struct loop_regs
   int multiple_uses;
 };
 
+
+struct loop_movables
+{
+  /* Head of movable chain.  */
+  struct movable *head;
+  /* Last movable in chain.  */
+  struct movable *last;
+  /* Number of movables in the loop.  */
+  int num;
+};
+
+
 /* Information pertaining to a loop.  */
 
 struct loop_info
 {
   /* Nonzero if there is a subroutine call in the current loop.  */
   int has_call;
+  /* Nonzero if there is a libcall in the current loop.  */
+  int has_libcall;
+  /* Nonzero if there is a non constant call in the current loop.  */
+  int has_nonconst_call;
   /* Nonzero if there is a volatile memory reference in the current
      loop.  */
   int has_volatile;
@@ -304,6 +323,8 @@ struct loop_info
   int num_mem_sets;
   /* The insn where the first of these was found.  */
   rtx first_loop_store_insn;
+  /* The chain of movable insns in loop.  */
+  struct loop_movables movables;
   /* The registers used the in loop.  */
   struct loop_regs regs;
   /* The induction variable information in loop.  */