1*e4b17023SJohn Marino /* Scalar evolution detector.
2*e4b17023SJohn Marino Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
3*e4b17023SJohn Marino Free Software Foundation, Inc.
4*e4b17023SJohn Marino Contributed by Sebastian Pop <s.pop@laposte.net>
5*e4b17023SJohn Marino
6*e4b17023SJohn Marino This file is part of GCC.
7*e4b17023SJohn Marino
8*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
9*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
10*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
11*e4b17023SJohn Marino version.
12*e4b17023SJohn Marino
13*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16*e4b17023SJohn Marino for more details.
17*e4b17023SJohn Marino
18*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
19*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see
20*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */
21*e4b17023SJohn Marino
22*e4b17023SJohn Marino #ifndef GCC_TREE_SCALAR_EVOLUTION_H
23*e4b17023SJohn Marino #define GCC_TREE_SCALAR_EVOLUTION_H
24*e4b17023SJohn Marino
25*e4b17023SJohn Marino extern tree number_of_latch_executions (struct loop *);
26*e4b17023SJohn Marino extern tree number_of_exit_cond_executions (struct loop *);
27*e4b17023SJohn Marino extern gimple get_loop_exit_condition (const struct loop *);
28*e4b17023SJohn Marino
29*e4b17023SJohn Marino extern void scev_initialize (void);
30*e4b17023SJohn Marino extern void scev_reset (void);
31*e4b17023SJohn Marino extern void scev_reset_htab (void);
32*e4b17023SJohn Marino extern void scev_finalize (void);
33*e4b17023SJohn Marino extern tree analyze_scalar_evolution (struct loop *, tree);
34*e4b17023SJohn Marino extern tree instantiate_scev (basic_block, struct loop *, tree);
35*e4b17023SJohn Marino extern tree resolve_mixers (struct loop *, tree);
36*e4b17023SJohn Marino extern void gather_stats_on_scev_database (void);
37*e4b17023SJohn Marino extern void scev_analysis (void);
38*e4b17023SJohn Marino extern unsigned int scev_const_prop (void);
39*e4b17023SJohn Marino extern bool expression_expensive_p (tree);
40*e4b17023SJohn Marino extern bool simple_iv (struct loop *, struct loop *, tree, affine_iv *, bool);
41*e4b17023SJohn Marino extern tree compute_overall_effect_of_inner_loop (struct loop *, tree);
42*e4b17023SJohn Marino
43*e4b17023SJohn Marino /* Returns the basic block preceding LOOP or ENTRY_BLOCK_PTR when the
44*e4b17023SJohn Marino loop is function's body. */
45*e4b17023SJohn Marino
46*e4b17023SJohn Marino static inline basic_block
block_before_loop(loop_p loop)47*e4b17023SJohn Marino block_before_loop (loop_p loop)
48*e4b17023SJohn Marino {
49*e4b17023SJohn Marino edge preheader = loop_preheader_edge (loop);
50*e4b17023SJohn Marino return (preheader ? preheader->src : ENTRY_BLOCK_PTR);
51*e4b17023SJohn Marino }
52*e4b17023SJohn Marino
53*e4b17023SJohn Marino /* Analyze all the parameters of the chrec that were left under a
54*e4b17023SJohn Marino symbolic form. LOOP is the loop in which symbolic names have to
55*e4b17023SJohn Marino be analyzed and instantiated. */
56*e4b17023SJohn Marino
57*e4b17023SJohn Marino static inline tree
instantiate_parameters(struct loop * loop,tree chrec)58*e4b17023SJohn Marino instantiate_parameters (struct loop *loop, tree chrec)
59*e4b17023SJohn Marino {
60*e4b17023SJohn Marino return instantiate_scev (block_before_loop (loop), loop, chrec);
61*e4b17023SJohn Marino }
62*e4b17023SJohn Marino
63*e4b17023SJohn Marino /* Returns the loop of the polynomial chrec CHREC. */
64*e4b17023SJohn Marino
65*e4b17023SJohn Marino static inline struct loop *
get_chrec_loop(const_tree chrec)66*e4b17023SJohn Marino get_chrec_loop (const_tree chrec)
67*e4b17023SJohn Marino {
68*e4b17023SJohn Marino return get_loop (CHREC_VARIABLE (chrec));
69*e4b17023SJohn Marino }
70*e4b17023SJohn Marino
71*e4b17023SJohn Marino #endif /* GCC_TREE_SCALAR_EVOLUTION_H */
72