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;
#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));
/* 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
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;
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)
{
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);
}
}
}
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);
static void
ignore_some_movables (movables)
- struct movables *movables;
+ struct loop_movables *movables;
{
register struct movable *m, *m1;
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)
static void
combine_movables (movables, regs)
- struct movables *movables;
+ struct loop_movables *movables;
struct loop_regs *regs;
{
register struct movable *m;
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);
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;
static void
move_movables (loop, movables, threshold, insn_count)
struct loop *loop;
- struct movables *movables;
+ struct loop_movables *movables;
int threshold;
int 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.
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. */
&& ! 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)
{