comparison gcc/cfgloopmanip.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Loop manipulation code for GNU compiler. 1 /* Loop manipulation code for GNU compiler.
2 Copyright (C) 2002-2018 Free Software Foundation, Inc. 2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 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 7 the terms of the GNU General Public License as published by the Free
30 #include "gimple-iterator.h" 30 #include "gimple-iterator.h"
31 #include "gimplify-me.h" 31 #include "gimplify-me.h"
32 #include "tree-ssa-loop-manip.h" 32 #include "tree-ssa-loop-manip.h"
33 #include "dumpfile.h" 33 #include "dumpfile.h"
34 34
35 static void copy_loops_to (struct loop **, int, 35 static void copy_loops_to (class loop **, int,
36 struct loop *); 36 class loop *);
37 static void loop_redirect_edge (edge, basic_block); 37 static void loop_redirect_edge (edge, basic_block);
38 static void remove_bbs (basic_block *, int); 38 static void remove_bbs (basic_block *, int);
39 static bool rpe_enum_p (const_basic_block, const void *); 39 static bool rpe_enum_p (const_basic_block, const void *);
40 static int find_path (edge, basic_block **); 40 static int find_path (edge, basic_block **);
41 static void fix_loop_placements (struct loop *, bool *); 41 static void fix_loop_placements (class loop *, bool *);
42 static bool fix_bb_placement (basic_block); 42 static bool fix_bb_placement (basic_block);
43 static void fix_bb_placements (basic_block, bool *, bitmap); 43 static void fix_bb_placements (basic_block, bool *, bitmap);
44 44
45 /* Checks whether basic block BB is dominated by DATA. */ 45 /* Checks whether basic block BB is dominated by DATA. */
46 static bool 46 static bool
87 static bool 87 static bool
88 fix_bb_placement (basic_block bb) 88 fix_bb_placement (basic_block bb)
89 { 89 {
90 edge e; 90 edge e;
91 edge_iterator ei; 91 edge_iterator ei;
92 struct loop *loop = current_loops->tree_root, *act; 92 class loop *loop = current_loops->tree_root, *act;
93 93
94 FOR_EACH_EDGE (e, ei, bb->succs) 94 FOR_EACH_EDGE (e, ei, bb->succs)
95 { 95 {
96 if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun)) 96 if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
97 continue; 97 continue;
120 120
121 IRRED_INVALIDATED is set to true if a change in the loop structures might 121 IRRED_INVALIDATED is set to true if a change in the loop structures might
122 invalidate the information about irreducible regions. */ 122 invalidate the information about irreducible regions. */
123 123
124 static bool 124 static bool
125 fix_loop_placement (struct loop *loop, bool *irred_invalidated) 125 fix_loop_placement (class loop *loop, bool *irred_invalidated)
126 { 126 {
127 unsigned i; 127 unsigned i;
128 edge e; 128 edge e;
129 vec<edge> exits = get_loop_exit_edges (loop); 129 vec<edge> exits = get_loop_exit_edges (loop);
130 struct loop *father = current_loops->tree_root, *act; 130 class loop *father = current_loops->tree_root, *act;
131 bool ret = false; 131 bool ret = false;
132 132
133 FOR_EACH_VEC_ELT (exits, i, e) 133 FOR_EACH_VEC_ELT (exits, i, e)
134 { 134 {
135 act = find_common_loop (loop, e->dest->loop_father); 135 act = find_common_loop (loop, e->dest->loop_father);
180 fix_bb_placements (basic_block from, 180 fix_bb_placements (basic_block from,
181 bool *irred_invalidated, 181 bool *irred_invalidated,
182 bitmap loop_closed_ssa_invalidated) 182 bitmap loop_closed_ssa_invalidated)
183 { 183 {
184 basic_block *queue, *qtop, *qbeg, *qend; 184 basic_block *queue, *qtop, *qbeg, *qend;
185 struct loop *base_loop, *target_loop; 185 class loop *base_loop, *target_loop;
186 edge e; 186 edge e;
187 187
188 /* We pass through blocks back-reachable from FROM, testing whether some 188 /* We pass through blocks back-reachable from FROM, testing whether some
189 of their successors moved to outer loop. It may be necessary to 189 of their successors moved to outer loop. It may be necessary to
190 iterate several times, but it is finite, as we stop unless we move 190 iterate several times, but it is finite, as we stop unless we move
253 253
254 /* Something has changed, insert predecessors into queue. */ 254 /* Something has changed, insert predecessors into queue. */
255 FOR_EACH_EDGE (e, ei, from->preds) 255 FOR_EACH_EDGE (e, ei, from->preds)
256 { 256 {
257 basic_block pred = e->src; 257 basic_block pred = e->src;
258 struct loop *nca; 258 class loop *nca;
259 259
260 if (e->flags & EDGE_IRREDUCIBLE_LOOP) 260 if (e->flags & EDGE_IRREDUCIBLE_LOOP)
261 *irred_invalidated = true; 261 *irred_invalidated = true;
262 262
263 if (bitmap_bit_p (in_queue, pred->index)) 263 if (bitmap_bit_p (in_queue, pred->index))
305 basic_block *rem_bbs, *bord_bbs, from, bb; 305 basic_block *rem_bbs, *bord_bbs, from, bb;
306 vec<basic_block> dom_bbs; 306 vec<basic_block> dom_bbs;
307 int i, nrem, n_bord_bbs; 307 int i, nrem, n_bord_bbs;
308 bool local_irred_invalidated = false; 308 bool local_irred_invalidated = false;
309 edge_iterator ei; 309 edge_iterator ei;
310 struct loop *l, *f; 310 class loop *l, *f;
311 311
312 if (! irred_invalidated) 312 if (! irred_invalidated)
313 irred_invalidated = &local_irred_invalidated; 313 irred_invalidated = &local_irred_invalidated;
314 314
315 if (!can_remove_branch_p (e)) 315 if (!can_remove_branch_p (e))
362 break; 362 break;
363 } 363 }
364 364
365 for (i = 0; i < nrem; i++) 365 for (i = 0; i < nrem; i++)
366 { 366 {
367 bb = rem_bbs[i];
368 FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs) 367 FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs)
369 if (ae->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) 368 if (ae->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
370 && !bitmap_bit_p (seen, ae->dest->index)) 369 && !bitmap_bit_p (seen, ae->dest->index))
371 { 370 {
372 bitmap_set_bit (seen, ae->dest->index); 371 bitmap_set_bit (seen, ae->dest->index);
426 } 425 }
427 426
428 /* Creates place for a new LOOP in loops structure of FN. */ 427 /* Creates place for a new LOOP in loops structure of FN. */
429 428
430 void 429 void
431 place_new_loop (struct function *fn, struct loop *loop) 430 place_new_loop (struct function *fn, class loop *loop)
432 { 431 {
433 loop->num = number_of_loops (fn); 432 loop->num = number_of_loops (fn);
434 vec_safe_push (loops_for_fn (fn)->larray, loop); 433 vec_safe_push (loops_for_fn (fn)->larray, loop);
435 } 434 }
436 435
437 /* Given LOOP structure with filled header and latch, find the body of the 436 /* Given LOOP structure with filled header and latch, find the body of the
438 corresponding loop and add it to loops tree. Insert the LOOP as a son of 437 corresponding loop and add it to loops tree. Insert the LOOP as a son of
439 outer. */ 438 outer. */
440 439
441 void 440 void
442 add_loop (struct loop *loop, struct loop *outer) 441 add_loop (class loop *loop, class loop *outer)
443 { 442 {
444 basic_block *bbs; 443 basic_block *bbs;
445 int i, n; 444 int i, n;
446 struct loop *subloop; 445 class loop *subloop;
447 edge e; 446 edge e;
448 edge_iterator ei; 447 edge_iterator ei;
449 448
450 /* Add it to loop structure. */ 449 /* Add it to loop structure. */
451 place_new_loop (cfun, loop); 450 place_new_loop (cfun, loop);
489 } 488 }
490 489
491 /* Scale profile of loop by P. */ 490 /* Scale profile of loop by P. */
492 491
493 void 492 void
494 scale_loop_frequencies (struct loop *loop, profile_probability p) 493 scale_loop_frequencies (class loop *loop, profile_probability p)
495 { 494 {
496 basic_block *bbs; 495 basic_block *bbs;
497 496
498 bbs = get_loop_body (loop); 497 bbs = get_loop_body (loop);
499 scale_bbs_frequencies (bbs, loop->num_nodes, p); 498 scale_bbs_frequencies (bbs, loop->num_nodes, p);
507 scaled to final count. This is necessary because loop iterations are 506 scaled to final count. This is necessary because loop iterations are
508 determined by comparing header edge count to latch ege count and thus 507 determined by comparing header edge count to latch ege count and thus
509 they need to be scaled synchronously. */ 508 they need to be scaled synchronously. */
510 509
511 void 510 void
512 scale_loop_profile (struct loop *loop, profile_probability p, 511 scale_loop_profile (class loop *loop, profile_probability p,
513 gcov_type iteration_bound) 512 gcov_type iteration_bound)
514 { 513 {
515 edge e, preheader_e; 514 edge e, preheader_e;
516 edge_iterator ei; 515 edge_iterator ei;
517 516
617 } 616 }
618 617
619 /* Recompute dominance information for basic blocks outside LOOP. */ 618 /* Recompute dominance information for basic blocks outside LOOP. */
620 619
621 static void 620 static void
622 update_dominators_in_loop (struct loop *loop) 621 update_dominators_in_loop (class loop *loop)
623 { 622 {
624 vec<basic_block> dom_bbs = vNULL; 623 vec<basic_block> dom_bbs = vNULL;
625 basic_block *body; 624 basic_block *body;
626 unsigned i; 625 unsigned i;
627 626
762 Both INITIAL_VALUE and UPPER_BOUND expressions are gimplified and 761 Both INITIAL_VALUE and UPPER_BOUND expressions are gimplified and
763 inserted on the loop entry edge. This implies that this function 762 inserted on the loop entry edge. This implies that this function
764 should be used only when the UPPER_BOUND expression is a loop 763 should be used only when the UPPER_BOUND expression is a loop
765 invariant. */ 764 invariant. */
766 765
767 struct loop * 766 class loop *
768 create_empty_loop_on_edge (edge entry_edge, 767 create_empty_loop_on_edge (edge entry_edge,
769 tree initial_value, 768 tree initial_value,
770 tree stride, tree upper_bound, 769 tree stride, tree upper_bound,
771 tree iv, 770 tree iv,
772 tree *iv_before, 771 tree *iv_before,
773 tree *iv_after, 772 tree *iv_after,
774 struct loop *outer) 773 class loop *outer)
775 { 774 {
776 basic_block loop_header, loop_latch, succ_bb, pred_bb; 775 basic_block loop_header, loop_latch, succ_bb, pred_bb;
777 struct loop *loop; 776 class loop *loop;
778 gimple_stmt_iterator gsi; 777 gimple_stmt_iterator gsi;
779 gimple_seq stmts; 778 gimple_seq stmts;
780 gcond *cond_expr; 779 gcond *cond_expr;
781 tree exit_test; 780 tree exit_test;
782 edge exit_e; 781 edge exit_e;
856 FALSE_EDGE of SWITCH_BB to original destination of HEADER_EDGE and 855 FALSE_EDGE of SWITCH_BB to original destination of HEADER_EDGE and
857 TRUE_EDGE of SWITCH_BB to original destination of LATCH_EDGE. 856 TRUE_EDGE of SWITCH_BB to original destination of LATCH_EDGE.
858 Returns the newly created loop. Frequencies and counts in the new loop 857 Returns the newly created loop. Frequencies and counts in the new loop
859 are scaled by FALSE_SCALE and in the old one by TRUE_SCALE. */ 858 are scaled by FALSE_SCALE and in the old one by TRUE_SCALE. */
860 859
861 struct loop * 860 class loop *
862 loopify (edge latch_edge, edge header_edge, 861 loopify (edge latch_edge, edge header_edge,
863 basic_block switch_bb, edge true_edge, edge false_edge, 862 basic_block switch_bb, edge true_edge, edge false_edge,
864 bool redirect_all_edges, profile_probability true_scale, 863 bool redirect_all_edges, profile_probability true_scale,
865 profile_probability false_scale) 864 profile_probability false_scale)
866 { 865 {
867 basic_block succ_bb = latch_edge->dest; 866 basic_block succ_bb = latch_edge->dest;
868 basic_block pred_bb = header_edge->src; 867 basic_block pred_bb = header_edge->src;
869 struct loop *loop = alloc_loop (); 868 class loop *loop = alloc_loop ();
870 struct loop *outer = loop_outer (succ_bb->loop_father); 869 class loop *outer = loop_outer (succ_bb->loop_father);
871 profile_count cnt; 870 profile_count cnt;
872 871
873 loop->header = header_edge->dest; 872 loop->header = header_edge->dest;
874 loop->latch = latch_edge->src; 873 loop->latch = latch_edge->src;
875 874
922 921
923 LOOP_CLOSED_SSA_INVALIDATED, if non-NULL, is a bitmap where we store 922 LOOP_CLOSED_SSA_INVALIDATED, if non-NULL, is a bitmap where we store
924 basic blocks that had non-trivial update on their loop_father.*/ 923 basic blocks that had non-trivial update on their loop_father.*/
925 924
926 void 925 void
927 unloop (struct loop *loop, bool *irred_invalidated, 926 unloop (class loop *loop, bool *irred_invalidated,
928 bitmap loop_closed_ssa_invalidated) 927 bitmap loop_closed_ssa_invalidated)
929 { 928 {
930 basic_block *body; 929 basic_block *body;
931 struct loop *ploop; 930 class loop *ploop;
932 unsigned i, n; 931 unsigned i, n;
933 basic_block latch = loop->latch; 932 basic_block latch = loop->latch;
934 bool dummy = false; 933 bool dummy = false;
935 934
936 if (loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP) 935 if (loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP)
977 976
978 IRRED_INVALIDATED is set to true if a change in the loop structures might 977 IRRED_INVALIDATED is set to true if a change in the loop structures might
979 invalidate the information about irreducible regions. */ 978 invalidate the information about irreducible regions. */
980 979
981 static void 980 static void
982 fix_loop_placements (struct loop *loop, bool *irred_invalidated) 981 fix_loop_placements (class loop *loop, bool *irred_invalidated)
983 { 982 {
984 struct loop *outer; 983 class loop *outer;
985 984
986 while (loop_outer (loop)) 985 while (loop_outer (loop))
987 { 986 {
988 outer = loop_outer (loop); 987 outer = loop_outer (loop);
989 if (!fix_loop_placement (loop, irred_invalidated)) 988 if (!fix_loop_placement (loop, irred_invalidated))
1002 1001
1003 /* Duplicate loop bounds and other information we store about 1002 /* Duplicate loop bounds and other information we store about
1004 the loop into its duplicate. */ 1003 the loop into its duplicate. */
1005 1004
1006 void 1005 void
1007 copy_loop_info (struct loop *loop, struct loop *target) 1006 copy_loop_info (class loop *loop, class loop *target)
1008 { 1007 {
1009 gcc_checking_assert (!target->any_upper_bound && !target->any_estimate); 1008 gcc_checking_assert (!target->any_upper_bound && !target->any_estimate);
1010 target->any_upper_bound = loop->any_upper_bound; 1009 target->any_upper_bound = loop->any_upper_bound;
1011 target->nb_iterations_upper_bound = loop->nb_iterations_upper_bound; 1010 target->nb_iterations_upper_bound = loop->nb_iterations_upper_bound;
1012 target->any_likely_upper_bound = loop->any_likely_upper_bound; 1011 target->any_likely_upper_bound = loop->any_likely_upper_bound;
1013 target->nb_iterations_likely_upper_bound 1012 target->nb_iterations_likely_upper_bound
1014 = loop->nb_iterations_likely_upper_bound; 1013 = loop->nb_iterations_likely_upper_bound;
1015 target->any_estimate = loop->any_estimate; 1014 target->any_estimate = loop->any_estimate;
1016 target->nb_iterations_estimate = loop->nb_iterations_estimate; 1015 target->nb_iterations_estimate = loop->nb_iterations_estimate;
1017 target->estimate_state = loop->estimate_state; 1016 target->estimate_state = loop->estimate_state;
1017 target->safelen = loop->safelen;
1018 target->simdlen = loop->simdlen;
1018 target->constraints = loop->constraints; 1019 target->constraints = loop->constraints;
1020 target->can_be_parallel = loop->can_be_parallel;
1019 target->warned_aggressive_loop_optimizations 1021 target->warned_aggressive_loop_optimizations
1020 |= loop->warned_aggressive_loop_optimizations; 1022 |= loop->warned_aggressive_loop_optimizations;
1023 target->dont_vectorize = loop->dont_vectorize;
1024 target->force_vectorize = loop->force_vectorize;
1021 target->in_oacc_kernels_region = loop->in_oacc_kernels_region; 1025 target->in_oacc_kernels_region = loop->in_oacc_kernels_region;
1026 target->unroll = loop->unroll;
1027 target->owned_clique = loop->owned_clique;
1022 } 1028 }
1023 1029
1024 /* Copies copy of LOOP as subloop of TARGET loop, placing newly 1030 /* Copies copy of LOOP as subloop of TARGET loop, placing newly
1025 created loop into loops structure. If AFTER is non-null 1031 created loop into loops structure. If AFTER is non-null
1026 the new loop is added at AFTER->next, otherwise in front of TARGETs 1032 the new loop is added at AFTER->next, otherwise in front of TARGETs
1027 sibling list. */ 1033 sibling list. */
1028 struct loop * 1034 class loop *
1029 duplicate_loop (struct loop *loop, struct loop *target, struct loop *after) 1035 duplicate_loop (class loop *loop, class loop *target, class loop *after)
1030 { 1036 {
1031 struct loop *cloop; 1037 class loop *cloop;
1032 cloop = alloc_loop (); 1038 cloop = alloc_loop ();
1033 place_new_loop (cfun, cloop); 1039 place_new_loop (cfun, cloop);
1034 1040
1035 copy_loop_info (loop, cloop); 1041 copy_loop_info (loop, cloop);
1036 1042
1045 1051
1046 /* Copies structure of subloops of LOOP into TARGET loop, placing 1052 /* Copies structure of subloops of LOOP into TARGET loop, placing
1047 newly created loops into loop tree at the end of TARGETs sibling 1053 newly created loops into loop tree at the end of TARGETs sibling
1048 list in the original order. */ 1054 list in the original order. */
1049 void 1055 void
1050 duplicate_subloops (struct loop *loop, struct loop *target) 1056 duplicate_subloops (class loop *loop, class loop *target)
1051 { 1057 {
1052 struct loop *aloop, *cloop, *tail; 1058 class loop *aloop, *cloop, *tail;
1053 1059
1054 for (tail = target->inner; tail && tail->next; tail = tail->next) 1060 for (tail = target->inner; tail && tail->next; tail = tail->next)
1055 ; 1061 ;
1056 for (aloop = loop->inner; aloop; aloop = aloop->next) 1062 for (aloop = loop->inner; aloop; aloop = aloop->next)
1057 { 1063 {
1064 1070
1065 /* Copies structure of subloops of N loops, stored in array COPIED_LOOPS, 1071 /* Copies structure of subloops of N loops, stored in array COPIED_LOOPS,
1066 into TARGET loop, placing newly created loops into loop tree adding 1072 into TARGET loop, placing newly created loops into loop tree adding
1067 them to TARGETs sibling list at the end in order. */ 1073 them to TARGETs sibling list at the end in order. */
1068 static void 1074 static void
1069 copy_loops_to (struct loop **copied_loops, int n, struct loop *target) 1075 copy_loops_to (class loop **copied_loops, int n, class loop *target)
1070 { 1076 {
1071 struct loop *aloop, *tail; 1077 class loop *aloop, *tail;
1072 int i; 1078 int i;
1073 1079
1074 for (tail = target->inner; tail && tail->next; tail = tail->next) 1080 for (tail = target->inner; tail && tail->next; tail = tail->next)
1075 ; 1081 ;
1076 for (i = 0; i < n; i++) 1082 for (i = 0; i < n; i++)
1092 redirect_edge_and_branch_force (e, dest); 1098 redirect_edge_and_branch_force (e, dest);
1093 } 1099 }
1094 1100
1095 /* Check whether LOOP's body can be duplicated. */ 1101 /* Check whether LOOP's body can be duplicated. */
1096 bool 1102 bool
1097 can_duplicate_loop_p (const struct loop *loop) 1103 can_duplicate_loop_p (const class loop *loop)
1098 { 1104 {
1099 int ret; 1105 int ret;
1100 basic_block *bbs = get_loop_body (loop); 1106 basic_block *bbs = get_loop_body (loop);
1101 1107
1102 ret = can_copy_bbs_p (bbs, loop->num_nodes); 1108 ret = can_copy_bbs_p (bbs, loop->num_nodes);
1116 are numbered in order given by control flow through them) into TO_REMOVE 1122 are numbered in order given by control flow through them) into TO_REMOVE
1117 array. Returns false if duplication is 1123 array. Returns false if duplication is
1118 impossible. */ 1124 impossible. */
1119 1125
1120 bool 1126 bool
1121 duplicate_loop_to_header_edge (struct loop *loop, edge e, 1127 duplicate_loop_to_header_edge (class loop *loop, edge e,
1122 unsigned int ndupl, sbitmap wont_exit, 1128 unsigned int ndupl, sbitmap wont_exit,
1123 edge orig, vec<edge> *to_remove, 1129 edge orig, vec<edge> *to_remove,
1124 int flags) 1130 int flags)
1125 { 1131 {
1126 struct loop *target, *aloop; 1132 class loop *target, *aloop;
1127 struct loop **orig_loops; 1133 class loop **orig_loops;
1128 unsigned n_orig_loops; 1134 unsigned n_orig_loops;
1129 basic_block header = loop->header, latch = loop->latch; 1135 basic_block header = loop->header, latch = loop->latch;
1130 basic_block *new_bbs, *bbs, *first_active; 1136 basic_block *new_bbs, *bbs, *first_active;
1131 basic_block new_bb, bb, first_active_latch = NULL; 1137 basic_block new_bb, bb, first_active_latch = NULL;
1132 edge ae, latch_edge; 1138 edge ae, latch_edge;
1268 1274
1269 /* Original loops. */ 1275 /* Original loops. */
1270 n_orig_loops = 0; 1276 n_orig_loops = 0;
1271 for (aloop = loop->inner; aloop; aloop = aloop->next) 1277 for (aloop = loop->inner; aloop; aloop = aloop->next)
1272 n_orig_loops++; 1278 n_orig_loops++;
1273 orig_loops = XNEWVEC (struct loop *, n_orig_loops); 1279 orig_loops = XNEWVEC (class loop *, n_orig_loops);
1274 for (aloop = loop->inner, i = 0; aloop; aloop = aloop->next, i++) 1280 for (aloop = loop->inner, i = 0; aloop; aloop = aloop->next, i++)
1275 orig_loops[i] = aloop; 1281 orig_loops[i] = aloop;
1276 1282
1277 set_loop_copy (loop, target); 1283 set_loop_copy (loop, target);
1278 1284
1445 } 1451 }
1446 1452
1447 /* True when a candidate preheader BLOCK has predecessors from LOOP. */ 1453 /* True when a candidate preheader BLOCK has predecessors from LOOP. */
1448 1454
1449 static bool 1455 static bool
1450 has_preds_from_loop (basic_block block, struct loop *loop) 1456 has_preds_from_loop (basic_block block, class loop *loop)
1451 { 1457 {
1452 edge e; 1458 edge e;
1453 edge_iterator ei; 1459 edge_iterator ei;
1454 1460
1455 FOR_EACH_EDGE (e, ei, block->preds) 1461 FOR_EACH_EDGE (e, ei, block->preds)
1465 to be a fallthru predecessor to the loop header and to have only 1471 to be a fallthru predecessor to the loop header and to have only
1466 predecessors from outside of the loop. 1472 predecessors from outside of the loop.
1467 The function also updates dominators. */ 1473 The function also updates dominators. */
1468 1474
1469 basic_block 1475 basic_block
1470 create_preheader (struct loop *loop, int flags) 1476 create_preheader (class loop *loop, int flags)
1471 { 1477 {
1472 edge e; 1478 edge e;
1473 basic_block dummy; 1479 basic_block dummy;
1474 int nentry = 0; 1480 int nentry = 0;
1475 bool irred = false; 1481 bool irred = false;
1565 /* Create preheaders for each loop; for meaning of FLAGS see create_preheader. */ 1571 /* Create preheaders for each loop; for meaning of FLAGS see create_preheader. */
1566 1572
1567 void 1573 void
1568 create_preheaders (int flags) 1574 create_preheaders (int flags)
1569 { 1575 {
1570 struct loop *loop; 1576 class loop *loop;
1571 1577
1572 if (!current_loops) 1578 if (!current_loops)
1573 return; 1579 return;
1574 1580
1575 FOR_EACH_LOOP (loop, 0) 1581 FOR_EACH_LOOP (loop, 0)
1580 /* Forces all loop latches to have only single successor. */ 1586 /* Forces all loop latches to have only single successor. */
1581 1587
1582 void 1588 void
1583 force_single_succ_latches (void) 1589 force_single_succ_latches (void)
1584 { 1590 {
1585 struct loop *loop; 1591 class loop *loop;
1586 edge e; 1592 edge e;
1587 1593
1588 FOR_EACH_LOOP (loop, 0) 1594 FOR_EACH_LOOP (loop, 0)
1589 { 1595 {
1590 if (loop->latch != loop->header && single_succ_p (loop->latch)) 1596 if (loop->latch != loop->header && single_succ_p (loop->latch))
1669 new loop should be scaled. 1675 new loop should be scaled.
1670 1676
1671 If PLACE_AFTER is true, we place the new loop after LOOP in the 1677 If PLACE_AFTER is true, we place the new loop after LOOP in the
1672 instruction stream, otherwise it is placed before LOOP. */ 1678 instruction stream, otherwise it is placed before LOOP. */
1673 1679
1674 struct loop * 1680 class loop *
1675 loop_version (struct loop *loop, 1681 loop_version (class loop *loop,
1676 void *cond_expr, basic_block *condition_bb, 1682 void *cond_expr, basic_block *condition_bb,
1677 profile_probability then_prob, profile_probability else_prob, 1683 profile_probability then_prob, profile_probability else_prob,
1678 profile_probability then_scale, profile_probability else_scale, 1684 profile_probability then_scale, profile_probability else_scale,
1679 bool place_after) 1685 bool place_after)
1680 { 1686 {
1681 basic_block first_head, second_head; 1687 basic_block first_head, second_head;
1682 edge entry, latch_edge, true_edge, false_edge; 1688 edge entry, latch_edge, true_edge, false_edge;
1683 int irred_flag; 1689 int irred_flag;
1684 struct loop *nloop; 1690 class loop *nloop;
1685 basic_block cond_bb; 1691 basic_block cond_bb;
1686 1692
1687 /* Record entry and latch edges for the loop */ 1693 /* Record entry and latch edges for the loop */
1688 entry = loop_preheader_edge (loop); 1694 entry = loop_preheader_edge (loop);
1689 irred_flag = entry->flags & EDGE_IRREDUCIBLE_LOOP; 1695 irred_flag = entry->flags & EDGE_IRREDUCIBLE_LOOP;