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