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