/* Natural loop functions
- Copyright (C) 1987, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright (C) 1987, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GCC.
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
+#ifndef GCC_CFGLOOP_H
+#define GCC_CFGLOOP_H
+
+#include "basic-block.h"
+/* For rtx_code. */
+#include "rtl.h"
+
/* Structure to hold decision about unrolling/peeling. */
enum lpt_dec
{
unsigned times;
};
-/* Description of loop for simple loop unrolling. */
-struct loop_desc
-{
- int postincr; /* 1 if increment/decrement is done after loop exit condition. */
- rtx stride; /* Value added to VAR in each iteration. */
- rtx var; /* Loop control variable. */
- enum machine_mode inner_mode;
- /* The mode from that it is extended. */
- enum rtx_code extend; /* With this extend. */
- rtx var_alts; /* List of definitions of its initial value. */
- rtx lim; /* Expression var is compared with. */
- rtx lim_alts; /* List of definitions of its initial value. */
- bool const_iter; /* True if it iterates constant number of times. */
- unsigned HOST_WIDE_INT niter;
- /* Number of iterations if it is constant. */
- bool may_be_zero; /* If we cannot determine that the first iteration will pass. */
- enum rtx_code cond; /* Exit condition. */
- int neg; /* Set to 1 if loop ends when condition is satisfied. */
- edge out_edge; /* The exit edge. */
- edge in_edge; /* And the other one. */
- int n_branches; /* Number of branches inside the loop. */
-};
-
/* Structure to hold information for each natural loop. */
struct loop
{
/* For loop unrolling/peeling decision. */
struct lpt_decision lpt_decision;
- /* Simple loop description. */
- int simple;
- struct loop_desc desc;
- int has_desc;
-
/* Number of loop insns. */
unsigned ninsns;
extern int flow_loop_scan (struct loop *, int);
extern void flow_loop_free (struct loop *);
void mark_irreducible_loops (struct loops *);
+extern void create_loop_notes (void);
/* Loop data structure manipulation/querying. */
extern void flow_loop_tree_node_add (struct loop *, struct loop *);
extern struct loop * find_common_loop (struct loop *, struct loop *);
extern int num_loop_insns (struct loop *);
extern int average_num_loop_insns (struct loop *);
+extern unsigned get_loop_level (const struct loop *);
/* Loops & cfg manipulation. */
extern basic_block *get_loop_body (const struct loop *);
extern void verify_loop_structure (struct loops *);
/* Loop analysis. */
-extern bool simple_loop_p (struct loop *, struct loop_desc *);
-extern rtx count_loop_iterations (struct loop_desc *, rtx, rtx);
extern bool just_once_each_iteration_p (struct loop *, basic_block);
extern unsigned expected_loop_iterations (const struct loop *);
unsigned first_special : 1;
};
-/* This should replace struct loop_desc. We keep this just so that we are
- able to compare the results. */
+/* The description of an exit from the loop and of the number of iterations
+ till we take the exit. */
struct niter_desc
{
extern void iv_analysis_loop_init (struct loop *);
extern rtx iv_get_reaching_def (rtx, rtx);
-extern bool iv_analyse (rtx, rtx, struct rtx_iv *);
+extern bool iv_analyze (rtx, rtx, struct rtx_iv *);
extern rtx get_iv_value (struct rtx_iv *, rtx);
extern void find_simple_exit (struct loop *, struct niter_desc *);
extern void iv_number_of_iterations (struct loop *, rtx, rtx,
return loop->aux;
}
+/* Register pressure estimation for induction variable optimizations & loop
+ invariant motion. */
+extern unsigned global_cost_for_size (unsigned, unsigned, unsigned);
+extern void init_set_costs (void);
+
/* Loop optimizer initialization. */
extern struct loops *loop_optimizer_init (FILE *);
extern void loop_optimizer_finalize (struct loops *, FILE *);
};
extern void unroll_and_peel_loops (struct loops *, int);
+extern void doloop_optimize_loops (struct loops *);
+extern void move_loop_invariants (struct loops *);
+
+#endif /* GCC_CFGLOOP_H */