re PR tree-optimization/55569 (ICE: in check_probability, at basic-block.h:944 with...
[platform/upstream/gcc.git] / gcc / cfgloop.h
1 /* Natural loop functions
2    Copyright (C) 1987, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3    2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #ifndef GCC_CFGLOOP_H
23 #define GCC_CFGLOOP_H
24
25 #include "basic-block.h"
26 #include "double-int.h"
27
28 #include "bitmap.h"
29 #include "sbitmap.h"
30
31 /* Structure to hold decision about unrolling/peeling.  */
32 enum lpt_dec
33 {
34   LPT_NONE,
35   LPT_PEEL_COMPLETELY,
36   LPT_PEEL_SIMPLE,
37   LPT_UNROLL_CONSTANT,
38   LPT_UNROLL_RUNTIME,
39   LPT_UNROLL_STUPID
40 };
41
42 struct GTY (()) lpt_decision {
43   enum lpt_dec decision;
44   unsigned times;
45 };
46
47 /* The type of extend applied to an IV.  */
48 enum iv_extend_code
49 {
50   IV_SIGN_EXTEND,
51   IV_ZERO_EXTEND,
52   IV_UNKNOWN_EXTEND
53 };
54
55 /* The structure describing a bound on number of iterations of a loop.  */
56
57 struct GTY ((chain_next ("%h.next"))) nb_iter_bound {
58   /* The statement STMT is executed at most ...  */
59   gimple stmt;
60
61   /* ... BOUND + 1 times (BOUND must be an unsigned constant).
62      The + 1 is added for the following reasons:
63
64      a) 0 would otherwise be unused, while we would need to care more about
65         overflows (as MAX + 1 is sometimes produced as the estimate on number
66         of executions of STMT).
67      b) it is consistent with the result of number_of_iterations_exit.  */
68   double_int bound;
69
70   /* True if the statement will cause the loop to be leaved the (at most)
71      BOUND + 1-st time it is executed, that is, all the statements after it
72      are executed at most BOUND times.  */
73   bool is_exit;
74
75   /* The next bound in the list.  */
76   struct nb_iter_bound *next;
77 };
78
79 /* Description of the loop exit.  */
80
81 struct GTY (()) loop_exit {
82   /* The exit edge.  */
83   edge e;
84
85   /* Previous and next exit in the list of the exits of the loop.  */
86   struct loop_exit *prev;
87   struct loop_exit *next;
88
89   /* Next element in the list of loops from that E exits.  */
90   struct loop_exit *next_e;
91 };
92
93 typedef struct loop *loop_p;
94
95 /* An integer estimation of the number of iterations.  Estimate_state
96    describes what is the state of the estimation.  */
97 enum loop_estimation
98 {
99   /* Estimate was not computed yet.  */
100   EST_NOT_COMPUTED,
101   /* Estimate is ready.  */
102   EST_AVAILABLE
103 };
104
105 /* Structure to hold information for each natural loop.  */
106 struct GTY ((chain_next ("%h.next"))) loop {
107   /* Index into loops array.  */
108   int num;
109
110   /* Number of loop insns.  */
111   unsigned ninsns;
112
113   /* Basic block of loop header.  */
114   basic_block header;
115
116   /* Basic block of loop latch.  */
117   basic_block latch;
118
119   /* For loop unrolling/peeling decision.  */
120   struct lpt_decision lpt_decision;
121
122   /* Average number of executed insns per iteration.  */
123   unsigned av_ninsns;
124
125   /* Number of blocks contained within the loop.  */
126   unsigned num_nodes;
127
128   /* Superloops of the loop, starting with the outermost loop.  */
129   vec<loop_p, va_gc> *superloops;
130
131   /* The first inner (child) loop or NULL if innermost loop.  */
132   struct loop *inner;
133
134   /* Link to the next (sibling) loop.  */
135   struct loop *next;
136
137   /* Auxiliary info specific to a pass.  */
138   PTR GTY ((skip (""))) aux;
139
140   /* The number of times the latch of the loop is executed.  This can be an
141      INTEGER_CST, or a symbolic expression representing the number of
142      iterations like "N - 1", or a COND_EXPR containing the runtime
143      conditions under which the number of iterations is non zero.
144
145      Don't access this field directly: number_of_latch_executions
146      computes and caches the computed information in this field.  */
147   tree nb_iterations;
148
149   /* An integer guaranteed to be greater or equal to nb_iterations.  Only
150      valid if any_upper_bound is true.  */
151   double_int nb_iterations_upper_bound;
152
153   /* An integer giving an estimate on nb_iterations.  Unlike
154      nb_iterations_upper_bound, there is no guarantee that it is at least
155      nb_iterations.  */
156   double_int nb_iterations_estimate;
157
158   bool any_upper_bound;
159   bool any_estimate;
160
161   /* True if the loop can be parallel.  */
162   bool can_be_parallel;
163
164   /* An integer estimation of the number of iterations.  Estimate_state
165      describes what is the state of the estimation.  */
166   enum loop_estimation estimate_state;
167
168   /* Upper bound on number of iterations of a loop.  */
169   struct nb_iter_bound *bounds;
170
171   /* Head of the cyclic list of the exits of the loop.  */
172   struct loop_exit *exits;
173 };
174
175 /* Flags for state of loop structure.  */
176 enum
177 {
178   LOOPS_HAVE_PREHEADERS = 1,
179   LOOPS_HAVE_SIMPLE_LATCHES = 2,
180   LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS = 4,
181   LOOPS_HAVE_RECORDED_EXITS = 8,
182   LOOPS_MAY_HAVE_MULTIPLE_LATCHES = 16,
183   LOOP_CLOSED_SSA = 32,
184   LOOPS_NEED_FIXUP = 64,
185   LOOPS_HAVE_FALLTHRU_PREHEADERS = 128
186 };
187
188 #define LOOPS_NORMAL (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES \
189                       | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
190 #define AVOID_CFG_MODIFICATIONS (LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
191
192 /* Structure to hold CFG information about natural loops within a function.  */
193 struct GTY (()) loops {
194   /* State of loops.  */
195   int state;
196
197   /* Array of the loops.  */
198   vec<loop_p, va_gc> *larray;
199
200   /* Maps edges to the list of their descriptions as loop exits.  Edges
201      whose sources or destinations have loop_father == NULL (which may
202      happen during the cfg manipulations) should not appear in EXITS.  */
203   htab_t GTY((param_is (struct loop_exit))) exits;
204
205   /* Pointer to root of loop hierarchy tree.  */
206   struct loop *tree_root;
207 };
208
209 /* Loop recognition.  */
210 extern int flow_loops_find (struct loops *);
211 extern void disambiguate_loops_with_multiple_latches (void);
212 extern void flow_loops_free (struct loops *);
213 extern void flow_loops_dump (FILE *,
214                              void (*)(const struct loop *, FILE *, int), int);
215 extern void flow_loop_dump (const struct loop *, FILE *,
216                             void (*)(const struct loop *, FILE *, int), int);
217 struct loop *alloc_loop (void);
218 extern void flow_loop_free (struct loop *);
219 int flow_loop_nodes_find (basic_block, struct loop *);
220 void fix_loop_structure (bitmap changed_bbs);
221 bool mark_irreducible_loops (void);
222 void release_recorded_exits (void);
223 void record_loop_exits (void);
224 void rescan_loop_exit (edge, bool, bool);
225
226 /* Loop data structure manipulation/querying.  */
227 extern void flow_loop_tree_node_add (struct loop *, struct loop *);
228 extern void flow_loop_tree_node_remove (struct loop *);
229 extern void add_loop (struct loop *, struct loop *);
230 extern bool flow_loop_nested_p  (const struct loop *, const struct loop *);
231 extern bool flow_bb_inside_loop_p (const struct loop *, const_basic_block);
232 extern struct loop * find_common_loop (struct loop *, struct loop *);
233 struct loop *superloop_at_depth (struct loop *, unsigned);
234 struct eni_weights_d;
235 extern unsigned tree_num_loop_insns (struct loop *, struct eni_weights_d *);
236 extern int num_loop_insns (const struct loop *);
237 extern int average_num_loop_insns (const struct loop *);
238 extern unsigned get_loop_level (const struct loop *);
239 extern bool loop_exit_edge_p (const struct loop *, const_edge);
240 extern bool loop_exits_to_bb_p (struct loop *, basic_block);
241 extern bool loop_exits_from_bb_p (struct loop *, basic_block);
242 extern void mark_loop_exit_edges (void);
243 extern location_t get_loop_location (struct loop *loop);
244
245 /* Loops & cfg manipulation.  */
246 extern basic_block *get_loop_body (const struct loop *);
247 extern unsigned get_loop_body_with_size (const struct loop *, basic_block *,
248                                          unsigned);
249 extern basic_block *get_loop_body_in_dom_order (const struct loop *);
250 extern basic_block *get_loop_body_in_bfs_order (const struct loop *);
251 extern basic_block *get_loop_body_in_custom_order (const struct loop *,
252                                int (*) (const void *, const void *));
253
254 extern vec<edge> get_loop_exit_edges (const struct loop *);
255 extern edge single_exit (const struct loop *);
256 extern edge single_likely_exit (struct loop *loop);
257 extern unsigned num_loop_branches (const struct loop *);
258
259 extern edge loop_preheader_edge (const struct loop *);
260 extern edge loop_latch_edge (const struct loop *);
261
262 extern void add_bb_to_loop (basic_block, struct loop *);
263 extern void remove_bb_from_loops (basic_block);
264
265 extern void cancel_loop_tree (struct loop *);
266 extern void delete_loop (struct loop *);
267
268 enum
269 {
270   CP_SIMPLE_PREHEADERS = 1,
271   CP_FALLTHRU_PREHEADERS = 2
272 };
273
274 basic_block create_preheader (struct loop *, int);
275 extern void create_preheaders (int);
276 extern void force_single_succ_latches (void);
277
278 extern void verify_loop_structure (void);
279
280 /* Loop analysis.  */
281 extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
282 gcov_type expected_loop_iterations_unbounded (const struct loop *);
283 extern unsigned expected_loop_iterations (const struct loop *);
284 extern rtx doloop_condition_get (rtx);
285
286 void estimate_numbers_of_iterations_loop (struct loop *);
287 void record_niter_bound (struct loop *, double_int, bool, bool);
288 bool estimated_loop_iterations (struct loop *, double_int *);
289 bool max_loop_iterations (struct loop *, double_int *);
290 HOST_WIDE_INT estimated_loop_iterations_int (struct loop *);
291 HOST_WIDE_INT max_loop_iterations_int (struct loop *);
292 bool max_stmt_executions (struct loop *, double_int *);
293 bool estimated_stmt_executions (struct loop *, double_int *);
294 HOST_WIDE_INT max_stmt_executions_int (struct loop *);
295 HOST_WIDE_INT estimated_stmt_executions_int (struct loop *);
296
297 /* Loop manipulation.  */
298 extern bool can_duplicate_loop_p (const struct loop *loop);
299
300 #define DLTHE_FLAG_UPDATE_FREQ  1       /* Update frequencies in
301                                            duplicate_loop_to_header_edge.  */
302 #define DLTHE_RECORD_COPY_NUMBER 2      /* Record copy number in the aux
303                                            field of newly create BB.  */
304 #define DLTHE_FLAG_COMPLETTE_PEEL 4     /* Update frequencies expecting
305                                            a complete peeling.  */
306
307 extern edge create_empty_if_region_on_edge (edge, tree);
308 extern struct loop *create_empty_loop_on_edge (edge, tree, tree, tree, tree,
309                                                tree *, tree *, struct loop *);
310 extern struct loop * duplicate_loop (struct loop *, struct loop *);
311 extern void copy_loop_info (struct loop *loop, struct loop *target);
312 extern void duplicate_subloops (struct loop *, struct loop *);
313 extern bool duplicate_loop_to_header_edge (struct loop *, edge,
314                                            unsigned, sbitmap, edge,
315                                            vec<edge> *, int);
316 extern struct loop *loopify (edge, edge,
317                              basic_block, edge, edge, bool,
318                              unsigned, unsigned);
319 struct loop * loop_version (struct loop *, void *,
320                             basic_block *, unsigned, unsigned, unsigned, bool);
321 extern bool remove_path (edge);
322 extern void unloop (struct loop *, bool *, bitmap);
323 extern void scale_loop_frequencies (struct loop *, int, int);
324
325 /* Induction variable analysis.  */
326
327 /* The description of induction variable.  The things are a bit complicated
328    due to need to handle subregs and extends.  The value of the object described
329    by it can be obtained as follows (all computations are done in extend_mode):
330
331    Value in i-th iteration is
332      delta + mult * extend_{extend_mode} (subreg_{mode} (base + i * step)).
333
334    If first_special is true, the value in the first iteration is
335      delta + mult * base
336
337    If extend = UNKNOWN, first_special must be false, delta 0, mult 1 and value is
338      subreg_{mode} (base + i * step)
339
340    The get_iv_value function can be used to obtain these expressions.
341
342    ??? Add a third mode field that would specify the mode in that inner
343    computation is done, which would enable it to be different from the
344    outer one?  */
345
346 struct rtx_iv
347 {
348   /* Its base and step (mode of base and step is supposed to be extend_mode,
349      see the description above).  */
350   rtx base, step;
351
352   /* The type of extend applied to it (IV_SIGN_EXTEND, IV_ZERO_EXTEND,
353      or IV_UNKNOWN_EXTEND).  */
354   enum iv_extend_code extend;
355
356   /* Operations applied in the extended mode.  */
357   rtx delta, mult;
358
359   /* The mode it is extended to.  */
360   enum machine_mode extend_mode;
361
362   /* The mode the variable iterates in.  */
363   enum machine_mode mode;
364
365   /* Whether the first iteration needs to be handled specially.  */
366   unsigned first_special : 1;
367 };
368
369 /* The description of an exit from the loop and of the number of iterations
370    till we take the exit.  */
371
372 struct niter_desc
373 {
374   /* The edge out of the loop.  */
375   edge out_edge;
376
377   /* The other edge leading from the condition.  */
378   edge in_edge;
379
380   /* True if we are able to say anything about number of iterations of the
381      loop.  */
382   bool simple_p;
383
384   /* True if the loop iterates the constant number of times.  */
385   bool const_iter;
386
387   /* Number of iterations if constant.  */
388   unsigned HOST_WIDEST_INT niter;
389
390   /* Assumptions under that the rest of the information is valid.  */
391   rtx assumptions;
392
393   /* Assumptions under that the loop ends before reaching the latch,
394      even if value of niter_expr says otherwise.  */
395   rtx noloop_assumptions;
396
397   /* Condition under that the loop is infinite.  */
398   rtx infinite;
399
400   /* Whether the comparison is signed.  */
401   bool signed_p;
402
403   /* The mode in that niter_expr should be computed.  */
404   enum machine_mode mode;
405
406   /* The number of iterations of the loop.  */
407   rtx niter_expr;
408 };
409
410 extern void iv_analysis_loop_init (struct loop *);
411 extern bool iv_analyze (rtx, rtx, struct rtx_iv *);
412 extern bool iv_analyze_result (rtx, rtx, struct rtx_iv *);
413 extern bool iv_analyze_expr (rtx, rtx, enum machine_mode, struct rtx_iv *);
414 extern rtx get_iv_value (struct rtx_iv *, rtx);
415 extern bool biv_p (rtx, rtx);
416 extern void find_simple_exit (struct loop *, struct niter_desc *);
417 extern void iv_analysis_done (void);
418
419 extern struct niter_desc *get_simple_loop_desc (struct loop *loop);
420 extern void free_simple_loop_desc (struct loop *loop);
421
422 static inline struct niter_desc *
423 simple_loop_desc (struct loop *loop)
424 {
425   return (struct niter_desc *) loop->aux;
426 }
427
428 /* Accessors for the loop structures.  */
429
430 /* Returns the loop with index NUM from current_loops.  */
431
432 static inline struct loop *
433 get_loop (unsigned num)
434 {
435   return (*current_loops->larray)[num];
436 }
437
438 /* Returns the number of superloops of LOOP.  */
439
440 static inline unsigned
441 loop_depth (const struct loop *loop)
442 {
443   return vec_safe_length (loop->superloops);
444 }
445
446 /* Returns the loop depth of the loop BB belongs to.  */
447
448 static inline int
449 bb_loop_depth (const_basic_block bb)
450 {
451   return bb->loop_father ? loop_depth (bb->loop_father) : 0;
452 }
453
454 /* Returns the immediate superloop of LOOP, or NULL if LOOP is the outermost
455    loop.  */
456
457 static inline struct loop *
458 loop_outer (const struct loop *loop)
459 {
460   unsigned n = vec_safe_length (loop->superloops);
461
462   if (n == 0)
463     return NULL;
464
465   return (*loop->superloops)[n - 1];
466 }
467
468 /* Returns true if LOOP has at least one exit edge.  */
469
470 static inline bool
471 loop_has_exit_edges (const struct loop *loop)
472 {
473   return loop->exits->next->e != NULL;
474 }
475
476 /* Returns the list of loops in current_loops.  */
477
478 static inline vec<loop_p, va_gc> *
479 get_loops (void)
480 {
481   if (!current_loops)
482     return NULL;
483
484   return current_loops->larray;
485 }
486
487 /* Returns the number of loops in current_loops (including the removed
488    ones and the fake loop that forms the root of the loop tree).  */
489
490 static inline unsigned
491 number_of_loops (void)
492 {
493   if (!current_loops)
494     return 0;
495
496   return vec_safe_length (current_loops->larray);
497 }
498
499 /* Returns true if state of the loops satisfies all properties
500    described by FLAGS.  */
501
502 static inline bool
503 loops_state_satisfies_p (unsigned flags)
504 {
505   return (current_loops->state & flags) == flags;
506 }
507
508 /* Sets FLAGS to the loops state.  */
509
510 static inline void
511 loops_state_set (unsigned flags)
512 {
513   current_loops->state |= flags;
514 }
515
516 /* Clears FLAGS from the loops state.  */
517
518 static inline void
519 loops_state_clear (unsigned flags)
520 {
521   if (!current_loops)
522     return;
523   current_loops->state &= ~flags;
524 }
525
526 /* Loop iterators.  */
527
528 /* Flags for loop iteration.  */
529
530 enum li_flags
531 {
532   LI_INCLUDE_ROOT = 1,          /* Include the fake root of the loop tree.  */
533   LI_FROM_INNERMOST = 2,        /* Iterate over the loops in the reverse order,
534                                    starting from innermost ones.  */
535   LI_ONLY_INNERMOST = 4         /* Iterate only over innermost loops.  */
536 };
537
538 /* The iterator for loops.  */
539
540 typedef struct
541 {
542   /* The list of loops to visit.  */
543   vec<int> to_visit;
544
545   /* The index of the actual loop.  */
546   unsigned idx;
547 } loop_iterator;
548
549 static inline void
550 fel_next (loop_iterator *li, loop_p *loop)
551 {
552   int anum;
553
554   while (li->to_visit.iterate (li->idx, &anum))
555     {
556       li->idx++;
557       *loop = get_loop (anum);
558       if (*loop)
559         return;
560     }
561
562   li->to_visit.release ();
563   *loop = NULL;
564 }
565
566 static inline void
567 fel_init (loop_iterator *li, loop_p *loop, unsigned flags)
568 {
569   struct loop *aloop;
570   unsigned i;
571   int mn;
572
573   li->idx = 0;
574   if (!current_loops)
575     {
576       li->to_visit.create (0);
577       *loop = NULL;
578       return;
579     }
580
581   li->to_visit.create (number_of_loops ());
582   mn = (flags & LI_INCLUDE_ROOT) ? 0 : 1;
583
584   if (flags & LI_ONLY_INNERMOST)
585     {
586       for (i = 0; vec_safe_iterate (current_loops->larray, i, &aloop); i++)
587         if (aloop != NULL
588             && aloop->inner == NULL
589             && aloop->num >= mn)
590           li->to_visit.quick_push (aloop->num);
591     }
592   else if (flags & LI_FROM_INNERMOST)
593     {
594       /* Push the loops to LI->TO_VISIT in postorder.  */
595       for (aloop = current_loops->tree_root;
596            aloop->inner != NULL;
597            aloop = aloop->inner)
598         continue;
599
600       while (1)
601         {
602           if (aloop->num >= mn)
603             li->to_visit.quick_push (aloop->num);
604
605           if (aloop->next)
606             {
607               for (aloop = aloop->next;
608                    aloop->inner != NULL;
609                    aloop = aloop->inner)
610                 continue;
611             }
612           else if (!loop_outer (aloop))
613             break;
614           else
615             aloop = loop_outer (aloop);
616         }
617     }
618   else
619     {
620       /* Push the loops to LI->TO_VISIT in preorder.  */
621       aloop = current_loops->tree_root;
622       while (1)
623         {
624           if (aloop->num >= mn)
625             li->to_visit.quick_push (aloop->num);
626
627           if (aloop->inner != NULL)
628             aloop = aloop->inner;
629           else
630             {
631               while (aloop != NULL && aloop->next == NULL)
632                 aloop = loop_outer (aloop);
633               if (aloop == NULL)
634                 break;
635               aloop = aloop->next;
636             }
637         }
638     }
639
640   fel_next (li, loop);
641 }
642
643 #define FOR_EACH_LOOP(LI, LOOP, FLAGS) \
644   for (fel_init (&(LI), &(LOOP), FLAGS); \
645        (LOOP); \
646        fel_next (&(LI), &(LOOP)))
647
648 #define FOR_EACH_LOOP_BREAK(LI) \
649   { \
650     (LI).to_visit.release (); \
651     break; \
652   }
653
654 /* The properties of the target.  */
655 struct target_cfgloop {
656   /* Number of available registers.  */
657   unsigned x_target_avail_regs;
658
659   /* Number of available registers that are call-clobbered.  */
660   unsigned x_target_clobbered_regs;
661
662   /* Number of registers reserved for temporary expressions.  */
663   unsigned x_target_res_regs;
664
665   /* The cost for register when there still is some reserve, but we are
666      approaching the number of available registers.  */
667   unsigned x_target_reg_cost[2];
668
669   /* The cost for register when we need to spill.  */
670   unsigned x_target_spill_cost[2];
671 };
672
673 extern struct target_cfgloop default_target_cfgloop;
674 #if SWITCHABLE_TARGET
675 extern struct target_cfgloop *this_target_cfgloop;
676 #else
677 #define this_target_cfgloop (&default_target_cfgloop)
678 #endif
679
680 #define target_avail_regs \
681   (this_target_cfgloop->x_target_avail_regs)
682 #define target_clobbered_regs \
683   (this_target_cfgloop->x_target_clobbered_regs)
684 #define target_res_regs \
685   (this_target_cfgloop->x_target_res_regs)
686 #define target_reg_cost \
687   (this_target_cfgloop->x_target_reg_cost)
688 #define target_spill_cost \
689   (this_target_cfgloop->x_target_spill_cost)
690
691 /* Register pressure estimation for induction variable optimizations & loop
692    invariant motion.  */
693 extern unsigned estimate_reg_pressure_cost (unsigned, unsigned, bool, bool);
694 extern void init_set_costs (void);
695
696 /* Loop optimizer initialization.  */
697 extern void loop_optimizer_init (unsigned);
698 extern void loop_optimizer_finalize (void);
699
700 /* Optimization passes.  */
701 extern void unswitch_loops (void);
702
703 enum
704 {
705   UAP_PEEL = 1,         /* Enables loop peeling.  */
706   UAP_UNROLL = 2,       /* Enables unrolling of loops if it seems profitable.  */
707   UAP_UNROLL_ALL = 4    /* Enables unrolling of all loops.  */
708 };
709
710 extern void unroll_and_peel_loops (int);
711 extern void doloop_optimize_loops (void);
712 extern void move_loop_invariants (void);
713 extern bool finite_loop_p (struct loop *);
714 extern void scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound);
715 extern vec<basic_block> get_loop_hot_path (const struct loop *loop);
716
717 /* Returns the outermost loop of the loop nest that contains LOOP.*/
718 static inline struct loop *
719 loop_outermost (struct loop *loop)
720 {
721   unsigned n = vec_safe_length (loop->superloops);
722
723   if (n <= 1)
724     return loop;
725
726   return (*loop->superloops)[1];
727 }
728
729
730 #endif /* GCC_CFGLOOP_H */