1*38fd1498Szrj /* Header file for SSA loop optimizations.
2*38fd1498Szrj Copyright (C) 2013-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
7*38fd1498Szrj the terms of the GNU General Public License as published by the Free
8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
9*38fd1498Szrj version.
10*38fd1498Szrj
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3. If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>. */
19*38fd1498Szrj
20*38fd1498Szrj #ifndef GCC_TREE_SSA_LOOP_H
21*38fd1498Szrj #define GCC_TREE_SSA_LOOP_H
22*38fd1498Szrj
23*38fd1498Szrj
24*38fd1498Szrj /* Affine iv. */
25*38fd1498Szrj
26*38fd1498Szrj struct affine_iv
27*38fd1498Szrj {
28*38fd1498Szrj /* Iv = BASE + STEP * i. */
29*38fd1498Szrj tree base, step;
30*38fd1498Szrj
31*38fd1498Szrj /* True if this iv does not overflow. */
32*38fd1498Szrj bool no_overflow;
33*38fd1498Szrj };
34*38fd1498Szrj
35*38fd1498Szrj /* Description of number of iterations of a loop. All the expressions inside
36*38fd1498Szrj the structure can be evaluated at the end of the loop's preheader
37*38fd1498Szrj (and due to ssa form, also anywhere inside the body of the loop). */
38*38fd1498Szrj
39*38fd1498Szrj struct tree_niter_desc
40*38fd1498Szrj {
41*38fd1498Szrj tree assumptions; /* The boolean expression. If this expression evaluates
42*38fd1498Szrj to false, then the other fields in this structure
43*38fd1498Szrj should not be used; there is no guarantee that they
44*38fd1498Szrj will be correct. */
45*38fd1498Szrj tree may_be_zero; /* The boolean expression. If it evaluates to true,
46*38fd1498Szrj the loop will exit in the first iteration (i.e.
47*38fd1498Szrj its latch will not be executed), even if the niter
48*38fd1498Szrj field says otherwise. */
49*38fd1498Szrj tree niter; /* The expression giving the number of iterations of
50*38fd1498Szrj a loop (provided that assumptions == true and
51*38fd1498Szrj may_be_zero == false), more precisely the number
52*38fd1498Szrj of executions of the latch of the loop. */
53*38fd1498Szrj widest_int max; /* The upper bound on the number of iterations of
54*38fd1498Szrj the loop. */
55*38fd1498Szrj
56*38fd1498Szrj /* The simplified shape of the exit condition. The loop exits if
57*38fd1498Szrj CONTROL CMP BOUND is false, where CMP is one of NE_EXPR,
58*38fd1498Szrj LT_EXPR, or GT_EXPR, and step of CONTROL is positive if CMP is
59*38fd1498Szrj LE_EXPR and negative if CMP is GE_EXPR. This information is used
60*38fd1498Szrj by loop unrolling. */
61*38fd1498Szrj affine_iv control;
62*38fd1498Szrj tree bound;
63*38fd1498Szrj enum tree_code cmp;
64*38fd1498Szrj };
65*38fd1498Szrj
66*38fd1498Szrj extern bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
67*38fd1498Szrj extern char *get_lsm_tmp_name (tree ref, unsigned n, const char *suffix = NULL);
68*38fd1498Szrj extern unsigned tree_num_loop_insns (struct loop *, struct eni_weights *);
69*38fd1498Szrj
70*38fd1498Szrj /* Returns the loop of the statement STMT. */
71*38fd1498Szrj
72*38fd1498Szrj static inline struct loop *
loop_containing_stmt(gimple * stmt)73*38fd1498Szrj loop_containing_stmt (gimple *stmt)
74*38fd1498Szrj {
75*38fd1498Szrj basic_block bb = gimple_bb (stmt);
76*38fd1498Szrj if (!bb)
77*38fd1498Szrj return NULL;
78*38fd1498Szrj
79*38fd1498Szrj return bb->loop_father;
80*38fd1498Szrj }
81*38fd1498Szrj
82*38fd1498Szrj #endif /* GCC_TREE_SSA_LOOP_H */
83