/* Loop optimization definitions for GNU C-Compiler
- Copyright (C) 1991, 1995, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1995, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of GNU CC.
Boston, MA 02111-1307, USA. */
#include "varray.h"
+#include "basic-block.h"
+
+/* Get the loop info pointer of a loop. */
+#define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux)
/* Get the luid of an insn. Catch the error of trying to reference the LUID
of an insn added during loop, since these don't have LUIDs. */
initialized in unrolled loop. */
unsigned shared : 1;
unsigned no_const_addval : 1; /* 1 if add_val does not contain a const. */
- unsigned derived : 1; /* For a giv, 1 if we decided to derive this
- giv from another one. */
+ unsigned multi_insn_incr : 1; /* 1 if multiple insns updated the biv. */
int lifetime; /* Length of life of this giv */
rtx derive_adjustment; /* If nonzero, is an adjustment to be
subtracted from add_val when this giv
struct induction *same; /* If this giv has been combined with another
giv, this points to the base giv. The base
giv will have COMBINED_WITH non-zero. */
+ struct induction *derived_from;/* For a giv, if we decided to derive this
+ giv from another one. */
HOST_WIDE_INT const_adjust; /* Used by loop unrolling, when an address giv
is split, and a constant is eliminated from
the address, the -constant is stored here
struct loop_info
{
+ /* Nonzero if there is a subroutine call in the current loop. */
+ int has_call;
+ /* Nonzero if there is a volatile memory reference in the current
+ loop. */
+ int has_volatile;
+ /* Nonzero if there is a tablejump in the current loop. */
+ int has_tablejump;
+ /* Nonzero if there are ways to leave the loop other than falling
+ off the end. */
+ int has_multiple_exit_targets;
+ /* Nonzero if there is an indirect jump in the current function. */
+ int has_indirect_jump;
/* Register or constant initial loop value. */
rtx initial_value;
/* Register or constant value used for comparison test. */
wider iterator, this number will be zero if the number of loop
iterations is too large for an unsigned integer to hold. */
unsigned HOST_WIDE_INT n_iterations;
- /* The loop unrolling factor.
- Potential values:
- 0: unrolled
- 1: not unrolled.
- -1: completely unrolled
- >0: holds the unroll exact factor. */
+ /* The number of times the loop body was unrolled. */
unsigned int unroll_number;
- /* Non-zero if the loop has a NOTE_INSN_LOOP_VTOP. */
- rtx vtop;
+ int used_count_register;
};
/* Definitions used by the basic induction variable discovery code. */
extern int *uid_luid;
extern int max_uid_for_loop;
-extern int *uid_loop_num;
-extern int *loop_outer_loop;
-extern rtx *loop_number_exit_labels;
-extern int *loop_number_exit_count;
extern int max_reg_before_loop;
-
+extern struct loop **uid_loop;
extern FILE *loop_dump_stream;
extern varray_type reg_iv_type;
/* Forward declarations for non-static functions declared in loop.c and
unroll.c. */
-int invariant_p PROTO((rtx));
-rtx get_condition_for_loop PROTO((rtx));
-void emit_iv_add_mult PROTO((rtx, rtx, rtx, rtx, rtx));
-
-/* Forward declarations for non-static functions declared in stmt.c. */
-void find_loop_tree_blocks PROTO((void));
-void unroll_block_trees PROTO((void));
-
-void unroll_loop PROTO((rtx, int, rtx, rtx, struct loop_info *, int));
-rtx biv_total_increment PROTO((struct iv_class *, rtx, rtx));
-unsigned HOST_WIDE_INT loop_iterations PROTO((rtx, rtx, struct loop_info *));
-int precondition_loop_p PROTO((rtx, struct loop_info *,
+int loop_invariant_p PARAMS ((const struct loop *, rtx));
+rtx get_condition_for_loop PARAMS ((const struct loop *, rtx));
+void emit_iv_add_mult PARAMS ((rtx, rtx, rtx, rtx, rtx));
+rtx express_from PARAMS ((struct induction *, struct induction *));
+
+void unroll_loop PARAMS ((struct loop *, int, rtx, int));
+rtx biv_total_increment PARAMS ((struct iv_class *));
+unsigned HOST_WIDE_INT loop_iterations PARAMS ((struct loop *));
+int precondition_loop_p PARAMS ((const struct loop *,
rtx *, rtx *, rtx *,
enum machine_mode *mode));
-rtx final_biv_value PROTO((struct iv_class *, rtx, rtx,
- unsigned HOST_WIDE_INT));
-rtx final_giv_value PROTO((struct induction *, rtx, rtx,
- unsigned HOST_WIDE_INT));
-void emit_unrolled_add PROTO((rtx, rtx, rtx));
-int back_branch_in_range_p PROTO((rtx, rtx, rtx));
-
-extern int *loop_unroll_number;
+rtx final_biv_value PARAMS ((const struct loop *, struct iv_class *));
+rtx final_giv_value PARAMS ((const struct loop *, struct induction *));
+void emit_unrolled_add PARAMS ((rtx, rtx, rtx));
+int back_branch_in_range_p PARAMS ((const struct loop *, rtx));
+int loop_insn_first_p PARAMS ((rtx, rtx));
+/* Forward declarations for non-static functions declared in stmt.c. */
+void find_loop_tree_blocks PARAMS ((void));
+void unroll_block_trees PARAMS ((void));