* gcc.dg/c11-complex-1.c: Use dg-add-options ieee.
[official-gcc.git] / gcc / tree-ssa-loop-ivcanon.c
blob97b95ab2d319e9559fbdd0a1f598592209f8c32c
1 /* Induction variable canonicalization and loop peeling.
2 Copyright (C) 2004-2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY 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.
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/>. */
20 /* This pass detects the loops that iterate a constant number of times,
21 adds a canonical induction variable (step -1, tested against 0)
22 and replaces the exit test. This enables the less powerful rtl
23 level analysis to use this information.
25 This might spoil the code in some cases (by increasing register pressure).
26 Note that in the case the new variable is not needed, ivopts will get rid
27 of it, so it might only be a problem when there are no other linear induction
28 variables. In that case the created optimization possibilities are likely
29 to pay up.
31 Additionally in case we detect that it is beneficial to unroll the
32 loop completely, we do it right here to expose the optimization
33 possibilities to the following passes. */
35 #include "config.h"
36 #include "system.h"
37 #include "coretypes.h"
38 #include "tm.h"
39 #include "tree.h"
40 #include "tm_p.h"
41 #include "basic-block.h"
42 #include "gimple-pretty-print.h"
43 #include "gimple.h"
44 #include "gimple-iterator.h"
45 #include "gimple-ssa.h"
46 #include "cgraph.h"
47 #include "tree-cfg.h"
48 #include "tree-phinodes.h"
49 #include "ssa-iterators.h"
50 #include "tree-ssanames.h"
51 #include "tree-ssa-loop-manip.h"
52 #include "tree-ssa-loop-niter.h"
53 #include "tree-ssa-loop.h"
54 #include "tree-into-ssa.h"
55 #include "cfgloop.h"
56 #include "tree-pass.h"
57 #include "tree-chrec.h"
58 #include "tree-scalar-evolution.h"
59 #include "params.h"
60 #include "flags.h"
61 #include "tree-inline.h"
62 #include "target.h"
63 #include "tree-cfgcleanup.h"
65 /* Specifies types of loops that may be unrolled. */
67 enum unroll_level
69 UL_SINGLE_ITER, /* Only loops that exit immediately in the first
70 iteration. */
71 UL_NO_GROWTH, /* Only loops whose unrolling will not cause increase
72 of code size. */
73 UL_ALL /* All suitable loops. */
76 /* Adds a canonical induction variable to LOOP iterating NITER times. EXIT
77 is the exit edge whose condition is replaced. */
79 static void
80 create_canonical_iv (struct loop *loop, edge exit, tree niter)
82 edge in;
83 tree type, var;
84 gimple cond;
85 gimple_stmt_iterator incr_at;
86 enum tree_code cmp;
88 if (dump_file && (dump_flags & TDF_DETAILS))
90 fprintf (dump_file, "Added canonical iv to loop %d, ", loop->num);
91 print_generic_expr (dump_file, niter, TDF_SLIM);
92 fprintf (dump_file, " iterations.\n");
95 cond = last_stmt (exit->src);
96 in = EDGE_SUCC (exit->src, 0);
97 if (in == exit)
98 in = EDGE_SUCC (exit->src, 1);
100 /* Note that we do not need to worry about overflows, since
101 type of niter is always unsigned and all comparisons are
102 just for equality/nonequality -- i.e. everything works
103 with a modulo arithmetics. */
105 type = TREE_TYPE (niter);
106 niter = fold_build2 (PLUS_EXPR, type,
107 niter,
108 build_int_cst (type, 1));
109 incr_at = gsi_last_bb (in->src);
110 create_iv (niter,
111 build_int_cst (type, -1),
112 NULL_TREE, loop,
113 &incr_at, false, NULL, &var);
115 cmp = (exit->flags & EDGE_TRUE_VALUE) ? EQ_EXPR : NE_EXPR;
116 gimple_cond_set_code (cond, cmp);
117 gimple_cond_set_lhs (cond, var);
118 gimple_cond_set_rhs (cond, build_int_cst (type, 0));
119 update_stmt (cond);
122 /* Describe size of loop as detected by tree_estimate_loop_size. */
123 struct loop_size
125 /* Number of instructions in the loop. */
126 int overall;
128 /* Number of instructions that will be likely optimized out in
129 peeled iterations of loop (i.e. computation based on induction
130 variable where induction variable starts at known constant.) */
131 int eliminated_by_peeling;
133 /* Same statistics for last iteration of loop: it is smaller because
134 instructions after exit are not executed. */
135 int last_iteration;
136 int last_iteration_eliminated_by_peeling;
138 /* If some IV computation will become constant. */
139 bool constant_iv;
141 /* Number of call stmts that are not a builtin and are pure or const
142 present on the hot path. */
143 int num_pure_calls_on_hot_path;
144 /* Number of call stmts that are not a builtin and are not pure nor const
145 present on the hot path. */
146 int num_non_pure_calls_on_hot_path;
147 /* Number of statements other than calls in the loop. */
148 int non_call_stmts_on_hot_path;
149 /* Number of branches seen on the hot path. */
150 int num_branches_on_hot_path;
153 /* Return true if OP in STMT will be constant after peeling LOOP. */
155 static bool
156 constant_after_peeling (tree op, gimple stmt, struct loop *loop)
158 affine_iv iv;
160 if (is_gimple_min_invariant (op))
161 return true;
163 /* We can still fold accesses to constant arrays when index is known. */
164 if (TREE_CODE (op) != SSA_NAME)
166 tree base = op;
168 /* First make fast look if we see constant array inside. */
169 while (handled_component_p (base))
170 base = TREE_OPERAND (base, 0);
171 if ((DECL_P (base)
172 && ctor_for_folding (base) != error_mark_node)
173 || CONSTANT_CLASS_P (base))
175 /* If so, see if we understand all the indices. */
176 base = op;
177 while (handled_component_p (base))
179 if (TREE_CODE (base) == ARRAY_REF
180 && !constant_after_peeling (TREE_OPERAND (base, 1), stmt, loop))
181 return false;
182 base = TREE_OPERAND (base, 0);
184 return true;
186 return false;
189 /* Induction variables are constants. */
190 if (!simple_iv (loop, loop_containing_stmt (stmt), op, &iv, false))
191 return false;
192 if (!is_gimple_min_invariant (iv.base))
193 return false;
194 if (!is_gimple_min_invariant (iv.step))
195 return false;
196 return true;
199 /* Computes an estimated number of insns in LOOP.
200 EXIT (if non-NULL) is an exite edge that will be eliminated in all but last
201 iteration of the loop.
202 EDGE_TO_CANCEL (if non-NULL) is an non-exit edge eliminated in the last iteration
203 of loop.
204 Return results in SIZE, estimate benefits for complete unrolling exiting by EXIT.
205 Stop estimating after UPPER_BOUND is met. Return true in this case. */
207 static bool
208 tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, struct loop_size *size,
209 int upper_bound)
211 basic_block *body = get_loop_body (loop);
212 gimple_stmt_iterator gsi;
213 unsigned int i;
214 bool after_exit;
215 vec<basic_block> path = get_loop_hot_path (loop);
217 size->overall = 0;
218 size->eliminated_by_peeling = 0;
219 size->last_iteration = 0;
220 size->last_iteration_eliminated_by_peeling = 0;
221 size->num_pure_calls_on_hot_path = 0;
222 size->num_non_pure_calls_on_hot_path = 0;
223 size->non_call_stmts_on_hot_path = 0;
224 size->num_branches_on_hot_path = 0;
225 size->constant_iv = 0;
227 if (dump_file && (dump_flags & TDF_DETAILS))
228 fprintf (dump_file, "Estimating sizes for loop %i\n", loop->num);
229 for (i = 0; i < loop->num_nodes; i++)
231 if (edge_to_cancel && body[i] != edge_to_cancel->src
232 && dominated_by_p (CDI_DOMINATORS, body[i], edge_to_cancel->src))
233 after_exit = true;
234 else
235 after_exit = false;
236 if (dump_file && (dump_flags & TDF_DETAILS))
237 fprintf (dump_file, " BB: %i, after_exit: %i\n", body[i]->index, after_exit);
239 for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi))
241 gimple stmt = gsi_stmt (gsi);
242 int num = estimate_num_insns (stmt, &eni_size_weights);
243 bool likely_eliminated = false;
244 bool likely_eliminated_last = false;
245 bool likely_eliminated_peeled = false;
247 if (dump_file && (dump_flags & TDF_DETAILS))
249 fprintf (dump_file, " size: %3i ", num);
250 print_gimple_stmt (dump_file, gsi_stmt (gsi), 0, 0);
253 /* Look for reasons why we might optimize this stmt away. */
255 if (gimple_has_side_effects (stmt))
257 /* Exit conditional. */
258 else if (exit && body[i] == exit->src
259 && stmt == last_stmt (exit->src))
261 if (dump_file && (dump_flags & TDF_DETAILS))
262 fprintf (dump_file, " Exit condition will be eliminated "
263 "in peeled copies.\n");
264 likely_eliminated_peeled = true;
266 else if (edge_to_cancel && body[i] == edge_to_cancel->src
267 && stmt == last_stmt (edge_to_cancel->src))
269 if (dump_file && (dump_flags & TDF_DETAILS))
270 fprintf (dump_file, " Exit condition will be eliminated "
271 "in last copy.\n");
272 likely_eliminated_last = true;
274 /* Sets of IV variables */
275 else if (gimple_code (stmt) == GIMPLE_ASSIGN
276 && constant_after_peeling (gimple_assign_lhs (stmt), stmt, loop))
278 if (dump_file && (dump_flags & TDF_DETAILS))
279 fprintf (dump_file, " Induction variable computation will"
280 " be folded away.\n");
281 likely_eliminated = true;
283 /* Assignments of IV variables. */
284 else if (gimple_code (stmt) == GIMPLE_ASSIGN
285 && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
286 && constant_after_peeling (gimple_assign_rhs1 (stmt), stmt, loop)
287 && (gimple_assign_rhs_class (stmt) != GIMPLE_BINARY_RHS
288 || constant_after_peeling (gimple_assign_rhs2 (stmt),
289 stmt, loop)))
291 size->constant_iv = true;
292 if (dump_file && (dump_flags & TDF_DETAILS))
293 fprintf (dump_file, " Constant expression will be folded away.\n");
294 likely_eliminated = true;
296 /* Conditionals. */
297 else if ((gimple_code (stmt) == GIMPLE_COND
298 && constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
299 && constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop))
300 || (gimple_code (stmt) == GIMPLE_SWITCH
301 && constant_after_peeling (gimple_switch_index (stmt), stmt, loop)))
303 if (dump_file && (dump_flags & TDF_DETAILS))
304 fprintf (dump_file, " Constant conditional.\n");
305 likely_eliminated = true;
308 size->overall += num;
309 if (likely_eliminated || likely_eliminated_peeled)
310 size->eliminated_by_peeling += num;
311 if (!after_exit)
313 size->last_iteration += num;
314 if (likely_eliminated || likely_eliminated_last)
315 size->last_iteration_eliminated_by_peeling += num;
317 if ((size->overall * 3 / 2 - size->eliminated_by_peeling
318 - size->last_iteration_eliminated_by_peeling) > upper_bound)
320 free (body);
321 path.release ();
322 return true;
326 while (path.length ())
328 basic_block bb = path.pop ();
329 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
331 gimple stmt = gsi_stmt (gsi);
332 if (gimple_code (stmt) == GIMPLE_CALL)
334 int flags = gimple_call_flags (stmt);
335 tree decl = gimple_call_fndecl (stmt);
337 if (decl && DECL_IS_BUILTIN (decl)
338 && is_inexpensive_builtin (decl))
340 else if (flags & (ECF_PURE | ECF_CONST))
341 size->num_pure_calls_on_hot_path++;
342 else
343 size->num_non_pure_calls_on_hot_path++;
344 size->num_branches_on_hot_path ++;
346 else if (gimple_code (stmt) != GIMPLE_CALL
347 && gimple_code (stmt) != GIMPLE_DEBUG)
348 size->non_call_stmts_on_hot_path++;
349 if (((gimple_code (stmt) == GIMPLE_COND
350 && (!constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
351 || constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop)))
352 || (gimple_code (stmt) == GIMPLE_SWITCH
353 && !constant_after_peeling (gimple_switch_index (stmt), stmt, loop)))
354 && (!exit || bb != exit->src))
355 size->num_branches_on_hot_path++;
358 path.release ();
359 if (dump_file && (dump_flags & TDF_DETAILS))
360 fprintf (dump_file, "size: %i-%i, last_iteration: %i-%i\n", size->overall,
361 size->eliminated_by_peeling, size->last_iteration,
362 size->last_iteration_eliminated_by_peeling);
364 free (body);
365 return false;
368 /* Estimate number of insns of completely unrolled loop.
369 It is (NUNROLL + 1) * size of loop body with taking into account
370 the fact that in last copy everything after exit conditional
371 is dead and that some instructions will be eliminated after
372 peeling.
374 Loop body is likely going to simplify further, this is difficult
375 to guess, we just decrease the result by 1/3. */
377 static unsigned HOST_WIDE_INT
378 estimated_unrolled_size (struct loop_size *size,
379 unsigned HOST_WIDE_INT nunroll)
381 HOST_WIDE_INT unr_insns = ((nunroll)
382 * (HOST_WIDE_INT) (size->overall
383 - size->eliminated_by_peeling));
384 if (!nunroll)
385 unr_insns = 0;
386 unr_insns += size->last_iteration - size->last_iteration_eliminated_by_peeling;
388 unr_insns = unr_insns * 2 / 3;
389 if (unr_insns <= 0)
390 unr_insns = 1;
392 return unr_insns;
395 /* Loop LOOP is known to not loop. See if there is an edge in the loop
396 body that can be remove to make the loop to always exit and at
397 the same time it does not make any code potentially executed
398 during the last iteration dead.
400 After complette unrolling we still may get rid of the conditional
401 on the exit in the last copy even if we have no idea what it does.
402 This is quite common case for loops of form
404 int a[5];
405 for (i=0;i<b;i++)
406 a[i]=0;
408 Here we prove the loop to iterate 5 times but we do not know
409 it from induction variable.
411 For now we handle only simple case where there is exit condition
412 just before the latch block and the latch block contains no statements
413 with side effect that may otherwise terminate the execution of loop
414 (such as by EH or by terminating the program or longjmp).
416 In the general case we may want to cancel the paths leading to statements
417 loop-niter identified as having undefined effect in the last iteration.
418 The other cases are hopefully rare and will be cleaned up later. */
420 static edge
421 loop_edge_to_cancel (struct loop *loop)
423 vec<edge> exits;
424 unsigned i;
425 edge edge_to_cancel;
426 gimple_stmt_iterator gsi;
428 /* We want only one predecestor of the loop. */
429 if (EDGE_COUNT (loop->latch->preds) > 1)
430 return NULL;
432 exits = get_loop_exit_edges (loop);
434 FOR_EACH_VEC_ELT (exits, i, edge_to_cancel)
436 /* Find the other edge than the loop exit
437 leaving the conditoinal. */
438 if (EDGE_COUNT (edge_to_cancel->src->succs) != 2)
439 continue;
440 if (EDGE_SUCC (edge_to_cancel->src, 0) == edge_to_cancel)
441 edge_to_cancel = EDGE_SUCC (edge_to_cancel->src, 1);
442 else
443 edge_to_cancel = EDGE_SUCC (edge_to_cancel->src, 0);
445 /* We only can handle conditionals. */
446 if (!(edge_to_cancel->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
447 continue;
449 /* We should never have conditionals in the loop latch. */
450 gcc_assert (edge_to_cancel->dest != loop->header);
452 /* Check that it leads to loop latch. */
453 if (edge_to_cancel->dest != loop->latch)
454 continue;
456 exits.release ();
458 /* Verify that the code in loop latch does nothing that may end program
459 execution without really reaching the exit. This may include
460 non-pure/const function calls, EH statements, volatile ASMs etc. */
461 for (gsi = gsi_start_bb (loop->latch); !gsi_end_p (gsi); gsi_next (&gsi))
462 if (gimple_has_side_effects (gsi_stmt (gsi)))
463 return NULL;
464 return edge_to_cancel;
466 exits.release ();
467 return NULL;
470 /* Remove all tests for exits that are known to be taken after LOOP was
471 peeled NPEELED times. Put gcc_unreachable before every statement
472 known to not be executed. */
474 static bool
475 remove_exits_and_undefined_stmts (struct loop *loop, unsigned int npeeled)
477 struct nb_iter_bound *elt;
478 bool changed = false;
480 for (elt = loop->bounds; elt; elt = elt->next)
482 /* If statement is known to be undefined after peeling, turn it
483 into unreachable (or trap when debugging experience is supposed
484 to be good). */
485 if (!elt->is_exit
486 && elt->bound.ult (double_int::from_uhwi (npeeled)))
488 gimple_stmt_iterator gsi = gsi_for_stmt (elt->stmt);
489 gimple stmt = gimple_build_call
490 (builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0);
492 gimple_set_location (stmt, gimple_location (elt->stmt));
493 gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
494 changed = true;
495 if (dump_file && (dump_flags & TDF_DETAILS))
497 fprintf (dump_file, "Forced statement unreachable: ");
498 print_gimple_stmt (dump_file, elt->stmt, 0, 0);
501 /* If we know the exit will be taken after peeling, update. */
502 else if (elt->is_exit
503 && elt->bound.ule (double_int::from_uhwi (npeeled)))
505 basic_block bb = gimple_bb (elt->stmt);
506 edge exit_edge = EDGE_SUCC (bb, 0);
508 if (dump_file && (dump_flags & TDF_DETAILS))
510 fprintf (dump_file, "Forced exit to be taken: ");
511 print_gimple_stmt (dump_file, elt->stmt, 0, 0);
513 if (!loop_exit_edge_p (loop, exit_edge))
514 exit_edge = EDGE_SUCC (bb, 1);
515 gcc_checking_assert (loop_exit_edge_p (loop, exit_edge));
516 if (exit_edge->flags & EDGE_TRUE_VALUE)
517 gimple_cond_make_true (elt->stmt);
518 else
519 gimple_cond_make_false (elt->stmt);
520 update_stmt (elt->stmt);
521 changed = true;
524 return changed;
527 /* Remove all exits that are known to be never taken because of the loop bound
528 discovered. */
530 static bool
531 remove_redundant_iv_tests (struct loop *loop)
533 struct nb_iter_bound *elt;
534 bool changed = false;
536 if (!loop->any_upper_bound)
537 return false;
538 for (elt = loop->bounds; elt; elt = elt->next)
540 /* Exit is pointless if it won't be taken before loop reaches
541 upper bound. */
542 if (elt->is_exit && loop->any_upper_bound
543 && loop->nb_iterations_upper_bound.ult (elt->bound))
545 basic_block bb = gimple_bb (elt->stmt);
546 edge exit_edge = EDGE_SUCC (bb, 0);
547 struct tree_niter_desc niter;
549 if (!loop_exit_edge_p (loop, exit_edge))
550 exit_edge = EDGE_SUCC (bb, 1);
552 /* Only when we know the actual number of iterations, not
553 just a bound, we can remove the exit. */
554 if (!number_of_iterations_exit (loop, exit_edge,
555 &niter, false, false)
556 || !integer_onep (niter.assumptions)
557 || !integer_zerop (niter.may_be_zero)
558 || !niter.niter
559 || TREE_CODE (niter.niter) != INTEGER_CST
560 || !loop->nb_iterations_upper_bound.ult
561 (tree_to_double_int (niter.niter)))
562 continue;
564 if (dump_file && (dump_flags & TDF_DETAILS))
566 fprintf (dump_file, "Removed pointless exit: ");
567 print_gimple_stmt (dump_file, elt->stmt, 0, 0);
569 if (exit_edge->flags & EDGE_TRUE_VALUE)
570 gimple_cond_make_false (elt->stmt);
571 else
572 gimple_cond_make_true (elt->stmt);
573 update_stmt (elt->stmt);
574 changed = true;
577 return changed;
580 /* Stores loops that will be unlooped after we process whole loop tree. */
581 static vec<loop_p> loops_to_unloop;
582 static vec<int> loops_to_unloop_nunroll;
584 /* Cancel all fully unrolled loops by putting __builtin_unreachable
585 on the latch edge.
586 We do it after all unrolling since unlooping moves basic blocks
587 across loop boundaries trashing loop closed SSA form as well
588 as SCEV info needed to be intact during unrolling.
590 IRRED_INVALIDATED is used to bookkeep if information about
591 irreducible regions may become invalid as a result
592 of the transformation.
593 LOOP_CLOSED_SSA_INVALIDATED is used to bookkepp the case
594 when we need to go into loop closed SSA form. */
596 static void
597 unloop_loops (bitmap loop_closed_ssa_invalidated,
598 bool *irred_invalidated)
600 while (loops_to_unloop.length ())
602 struct loop *loop = loops_to_unloop.pop ();
603 int n_unroll = loops_to_unloop_nunroll.pop ();
604 basic_block latch = loop->latch;
605 edge latch_edge = loop_latch_edge (loop);
606 int flags = latch_edge->flags;
607 location_t locus = latch_edge->goto_locus;
608 gimple stmt;
609 gimple_stmt_iterator gsi;
611 remove_exits_and_undefined_stmts (loop, n_unroll);
613 /* Unloop destroys the latch edge. */
614 unloop (loop, irred_invalidated, loop_closed_ssa_invalidated);
616 /* Create new basic block for the latch edge destination and wire
617 it in. */
618 stmt = gimple_build_call (builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0);
619 latch_edge = make_edge (latch, create_basic_block (NULL, NULL, latch), flags);
620 latch_edge->probability = 0;
621 latch_edge->count = 0;
622 latch_edge->flags |= flags;
623 latch_edge->goto_locus = locus;
625 latch_edge->dest->loop_father = current_loops->tree_root;
626 latch_edge->dest->count = 0;
627 latch_edge->dest->frequency = 0;
628 set_immediate_dominator (CDI_DOMINATORS, latch_edge->dest, latch_edge->src);
630 gsi = gsi_start_bb (latch_edge->dest);
631 gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
633 loops_to_unloop.release ();
634 loops_to_unloop_nunroll.release ();
637 /* Tries to unroll LOOP completely, i.e. NITER times.
638 UL determines which loops we are allowed to unroll.
639 EXIT is the exit of the loop that should be eliminated.
640 MAXITER specfy bound on number of iterations, -1 if it is
641 not known or too large for HOST_WIDE_INT. The location
642 LOCUS corresponding to the loop is used when emitting
643 a summary of the unroll to the dump file. */
645 static bool
646 try_unroll_loop_completely (struct loop *loop,
647 edge exit, tree niter,
648 enum unroll_level ul,
649 HOST_WIDE_INT maxiter,
650 location_t locus)
652 unsigned HOST_WIDE_INT n_unroll, ninsns, max_unroll, unr_insns;
653 gimple cond;
654 struct loop_size size;
655 bool n_unroll_found = false;
656 edge edge_to_cancel = NULL;
658 /* See if we proved number of iterations to be low constant.
660 EXIT is an edge that will be removed in all but last iteration of
661 the loop.
663 EDGE_TO_CACNEL is an edge that will be removed from the last iteration
664 of the unrolled sequence and is expected to make the final loop not
665 rolling.
667 If the number of execution of loop is determined by standard induction
668 variable test, then EXIT and EDGE_TO_CANCEL are the two edges leaving
669 from the iv test. */
670 if (tree_fits_uhwi_p (niter))
672 n_unroll = tree_to_uhwi (niter);
673 n_unroll_found = true;
674 edge_to_cancel = EDGE_SUCC (exit->src, 0);
675 if (edge_to_cancel == exit)
676 edge_to_cancel = EDGE_SUCC (exit->src, 1);
678 /* We do not know the number of iterations and thus we can not eliminate
679 the EXIT edge. */
680 else
681 exit = NULL;
683 /* See if we can improve our estimate by using recorded loop bounds. */
684 if (maxiter >= 0
685 && (!n_unroll_found || (unsigned HOST_WIDE_INT)maxiter < n_unroll))
687 n_unroll = maxiter;
688 n_unroll_found = true;
689 /* Loop terminates before the IV variable test, so we can not
690 remove it in the last iteration. */
691 edge_to_cancel = NULL;
694 if (!n_unroll_found)
695 return false;
697 max_unroll = PARAM_VALUE (PARAM_MAX_COMPLETELY_PEEL_TIMES);
698 if (n_unroll > max_unroll)
699 return false;
701 if (!edge_to_cancel)
702 edge_to_cancel = loop_edge_to_cancel (loop);
704 if (n_unroll)
706 sbitmap wont_exit;
707 edge e;
708 unsigned i;
709 bool large;
710 vec<edge> to_remove = vNULL;
711 if (ul == UL_SINGLE_ITER)
712 return false;
714 large = tree_estimate_loop_size
715 (loop, exit, edge_to_cancel, &size,
716 PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS));
717 ninsns = size.overall;
718 if (large)
720 if (dump_file && (dump_flags & TDF_DETAILS))
721 fprintf (dump_file, "Not unrolling loop %d: it is too large.\n",
722 loop->num);
723 return false;
726 unr_insns = estimated_unrolled_size (&size, n_unroll);
727 if (dump_file && (dump_flags & TDF_DETAILS))
729 fprintf (dump_file, " Loop size: %d\n", (int) ninsns);
730 fprintf (dump_file, " Estimated size after unrolling: %d\n",
731 (int) unr_insns);
734 /* If the code is going to shrink, we don't need to be extra cautious
735 on guessing if the unrolling is going to be profitable. */
736 if (unr_insns
737 /* If there is IV variable that will become constant, we save
738 one instruction in the loop prologue we do not account
739 otherwise. */
740 <= ninsns + (size.constant_iv != false))
742 /* We unroll only inner loops, because we do not consider it profitable
743 otheriwse. We still can cancel loopback edge of not rolling loop;
744 this is always a good idea. */
745 else if (ul == UL_NO_GROWTH)
747 if (dump_file && (dump_flags & TDF_DETAILS))
748 fprintf (dump_file, "Not unrolling loop %d: size would grow.\n",
749 loop->num);
750 return false;
752 /* Outer loops tend to be less interesting candidates for complette
753 unrolling unless we can do a lot of propagation into the inner loop
754 body. For now we disable outer loop unrolling when the code would
755 grow. */
756 else if (loop->inner)
758 if (dump_file && (dump_flags & TDF_DETAILS))
759 fprintf (dump_file, "Not unrolling loop %d: "
760 "it is not innermost and code would grow.\n",
761 loop->num);
762 return false;
764 /* If there is call on a hot path through the loop, then
765 there is most probably not much to optimize. */
766 else if (size.num_non_pure_calls_on_hot_path)
768 if (dump_file && (dump_flags & TDF_DETAILS))
769 fprintf (dump_file, "Not unrolling loop %d: "
770 "contains call and code would grow.\n",
771 loop->num);
772 return false;
774 /* If there is pure/const call in the function, then we
775 can still optimize the unrolled loop body if it contains
776 some other interesting code than the calls and code
777 storing or cumulating the return value. */
778 else if (size.num_pure_calls_on_hot_path
779 /* One IV increment, one test, one ivtmp store
780 and one useful stmt. That is about minimal loop
781 doing pure call. */
782 && (size.non_call_stmts_on_hot_path
783 <= 3 + size.num_pure_calls_on_hot_path))
785 if (dump_file && (dump_flags & TDF_DETAILS))
786 fprintf (dump_file, "Not unrolling loop %d: "
787 "contains just pure calls and code would grow.\n",
788 loop->num);
789 return false;
791 /* Complette unrolling is major win when control flow is removed and
792 one big basic block is created. If the loop contains control flow
793 the optimization may still be a win because of eliminating the loop
794 overhead but it also may blow the branch predictor tables.
795 Limit number of branches on the hot path through the peeled
796 sequence. */
797 else if (size.num_branches_on_hot_path * (int)n_unroll
798 > PARAM_VALUE (PARAM_MAX_PEEL_BRANCHES))
800 if (dump_file && (dump_flags & TDF_DETAILS))
801 fprintf (dump_file, "Not unrolling loop %d: "
802 " number of branches on hot path in the unrolled sequence"
803 " reach --param max-peel-branches limit.\n",
804 loop->num);
805 return false;
807 else if (unr_insns
808 > (unsigned) PARAM_VALUE (PARAM_MAX_COMPLETELY_PEELED_INSNS))
810 if (dump_file && (dump_flags & TDF_DETAILS))
811 fprintf (dump_file, "Not unrolling loop %d: "
812 "(--param max-completely-peeled-insns limit reached).\n",
813 loop->num);
814 return false;
817 initialize_original_copy_tables ();
818 wont_exit = sbitmap_alloc (n_unroll + 1);
819 bitmap_ones (wont_exit);
820 bitmap_clear_bit (wont_exit, 0);
822 if (!gimple_duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
823 n_unroll, wont_exit,
824 exit, &to_remove,
825 DLTHE_FLAG_UPDATE_FREQ
826 | DLTHE_FLAG_COMPLETTE_PEEL))
828 free_original_copy_tables ();
829 free (wont_exit);
830 if (dump_file && (dump_flags & TDF_DETAILS))
831 fprintf (dump_file, "Failed to duplicate the loop\n");
832 return false;
835 FOR_EACH_VEC_ELT (to_remove, i, e)
837 bool ok = remove_path (e);
838 gcc_assert (ok);
841 to_remove.release ();
842 free (wont_exit);
843 free_original_copy_tables ();
847 /* Remove the conditional from the last copy of the loop. */
848 if (edge_to_cancel)
850 cond = last_stmt (edge_to_cancel->src);
851 if (edge_to_cancel->flags & EDGE_TRUE_VALUE)
852 gimple_cond_make_false (cond);
853 else
854 gimple_cond_make_true (cond);
855 update_stmt (cond);
856 /* Do not remove the path. Doing so may remove outer loop
857 and confuse bookkeeping code in tree_unroll_loops_completelly. */
860 /* Store the loop for later unlooping and exit removal. */
861 loops_to_unloop.safe_push (loop);
862 loops_to_unloop_nunroll.safe_push (n_unroll);
864 if (dump_enabled_p ())
866 if (!n_unroll)
867 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, locus,
868 "loop turned into non-loop; it never loops\n");
869 else
871 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, locus,
872 "loop with %d iterations completely unrolled",
873 (int) (n_unroll + 1));
874 if (profile_info)
875 dump_printf (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS,
876 " (header execution count %d)",
877 (int)loop->header->count);
878 dump_printf (MSG_OPTIMIZED_LOCATIONS | TDF_DETAILS, "\n");
882 if (dump_file && (dump_flags & TDF_DETAILS))
884 if (exit)
885 fprintf (dump_file, "Exit condition of peeled iterations was "
886 "eliminated.\n");
887 if (edge_to_cancel)
888 fprintf (dump_file, "Last iteration exit edge was proved true.\n");
889 else
890 fprintf (dump_file, "Latch of last iteration was marked by "
891 "__builtin_unreachable ().\n");
894 return true;
897 /* Adds a canonical induction variable to LOOP if suitable.
898 CREATE_IV is true if we may create a new iv. UL determines
899 which loops we are allowed to completely unroll. If TRY_EVAL is true, we try
900 to determine the number of iterations of a loop by direct evaluation.
901 Returns true if cfg is changed. */
903 static bool
904 canonicalize_loop_induction_variables (struct loop *loop,
905 bool create_iv, enum unroll_level ul,
906 bool try_eval)
908 edge exit = NULL;
909 tree niter;
910 HOST_WIDE_INT maxiter;
911 bool modified = false;
912 location_t locus = UNKNOWN_LOCATION;
914 niter = number_of_latch_executions (loop);
915 exit = single_exit (loop);
916 if (TREE_CODE (niter) == INTEGER_CST)
917 locus = gimple_location (last_stmt (exit->src));
918 else
920 /* If the loop has more than one exit, try checking all of them
921 for # of iterations determinable through scev. */
922 if (!exit)
923 niter = find_loop_niter (loop, &exit);
925 /* Finally if everything else fails, try brute force evaluation. */
926 if (try_eval
927 && (chrec_contains_undetermined (niter)
928 || TREE_CODE (niter) != INTEGER_CST))
929 niter = find_loop_niter_by_eval (loop, &exit);
931 if (exit)
932 locus = gimple_location (last_stmt (exit->src));
934 if (TREE_CODE (niter) != INTEGER_CST)
935 exit = NULL;
938 /* We work exceptionally hard here to estimate the bound
939 by find_loop_niter_by_eval. Be sure to keep it for future. */
940 if (niter && TREE_CODE (niter) == INTEGER_CST)
942 record_niter_bound (loop, tree_to_double_int (niter),
943 exit == single_likely_exit (loop), true);
946 /* Force re-computation of loop bounds so we can remove redundant exits. */
947 maxiter = max_loop_iterations_int (loop);
949 if (dump_file && (dump_flags & TDF_DETAILS)
950 && TREE_CODE (niter) == INTEGER_CST)
952 fprintf (dump_file, "Loop %d iterates ", loop->num);
953 print_generic_expr (dump_file, niter, TDF_SLIM);
954 fprintf (dump_file, " times.\n");
956 if (dump_file && (dump_flags & TDF_DETAILS)
957 && maxiter >= 0)
959 fprintf (dump_file, "Loop %d iterates at most %i times.\n", loop->num,
960 (int)maxiter);
963 /* Remove exits that are known to be never taken based on loop bound.
964 Needs to be called after compilation of max_loop_iterations_int that
965 populates the loop bounds. */
966 modified |= remove_redundant_iv_tests (loop);
968 if (try_unroll_loop_completely (loop, exit, niter, ul, maxiter, locus))
969 return true;
971 if (create_iv
972 && niter && !chrec_contains_undetermined (niter)
973 && exit && just_once_each_iteration_p (loop, exit->src))
974 create_canonical_iv (loop, exit, niter);
976 return modified;
979 /* The main entry point of the pass. Adds canonical induction variables
980 to the suitable loops. */
982 unsigned int
983 canonicalize_induction_variables (void)
985 loop_iterator li;
986 struct loop *loop;
987 bool changed = false;
988 bool irred_invalidated = false;
989 bitmap loop_closed_ssa_invalidated = BITMAP_ALLOC (NULL);
991 free_numbers_of_iterations_estimates ();
992 estimate_numbers_of_iterations ();
994 FOR_EACH_LOOP (li, loop, LI_FROM_INNERMOST)
996 changed |= canonicalize_loop_induction_variables (loop,
997 true, UL_SINGLE_ITER,
998 true);
1000 gcc_assert (!need_ssa_update_p (cfun));
1002 unloop_loops (loop_closed_ssa_invalidated, &irred_invalidated);
1003 if (irred_invalidated
1004 && loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
1005 mark_irreducible_loops ();
1007 /* Clean up the information about numbers of iterations, since brute force
1008 evaluation could reveal new information. */
1009 scev_reset ();
1011 if (!bitmap_empty_p (loop_closed_ssa_invalidated))
1013 gcc_checking_assert (loops_state_satisfies_p (LOOP_CLOSED_SSA));
1014 rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
1016 BITMAP_FREE (loop_closed_ssa_invalidated);
1018 if (changed)
1019 return TODO_cleanup_cfg;
1020 return 0;
1023 /* Propagate VAL into all uses of SSA_NAME. */
1025 static void
1026 propagate_into_all_uses (tree ssa_name, tree val)
1028 imm_use_iterator iter;
1029 gimple use_stmt;
1031 FOR_EACH_IMM_USE_STMT (use_stmt, iter, ssa_name)
1033 gimple_stmt_iterator use_stmt_gsi = gsi_for_stmt (use_stmt);
1034 use_operand_p use;
1036 FOR_EACH_IMM_USE_ON_STMT (use, iter)
1037 SET_USE (use, val);
1039 if (is_gimple_assign (use_stmt)
1040 && get_gimple_rhs_class (gimple_assign_rhs_code (use_stmt))
1041 == GIMPLE_SINGLE_RHS)
1043 tree rhs = gimple_assign_rhs1 (use_stmt);
1045 if (TREE_CODE (rhs) == ADDR_EXPR)
1046 recompute_tree_invariant_for_addr_expr (rhs);
1049 fold_stmt_inplace (&use_stmt_gsi);
1050 update_stmt (use_stmt);
1051 maybe_clean_or_replace_eh_stmt (use_stmt, use_stmt);
1055 /* Propagate constant SSA_NAMEs defined in basic block BB. */
1057 static void
1058 propagate_constants_for_unrolling (basic_block bb)
1060 gimple_stmt_iterator gsi;
1062 /* Look for degenerate PHI nodes with constant argument. */
1063 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); )
1065 gimple phi = gsi_stmt (gsi);
1066 tree result = gimple_phi_result (phi);
1067 tree arg = gimple_phi_arg_def (phi, 0);
1069 if (gimple_phi_num_args (phi) == 1 && TREE_CODE (arg) == INTEGER_CST)
1071 propagate_into_all_uses (result, arg);
1072 gsi_remove (&gsi, true);
1073 release_ssa_name (result);
1075 else
1076 gsi_next (&gsi);
1079 /* Look for assignments to SSA names with constant RHS. */
1080 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
1082 gimple stmt = gsi_stmt (gsi);
1083 tree lhs;
1085 if (is_gimple_assign (stmt)
1086 && gimple_assign_rhs_code (stmt) == INTEGER_CST
1087 && (lhs = gimple_assign_lhs (stmt), TREE_CODE (lhs) == SSA_NAME)
1088 && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
1090 propagate_into_all_uses (lhs, gimple_assign_rhs1 (stmt));
1091 gsi_remove (&gsi, true);
1092 release_ssa_name (lhs);
1094 else
1095 gsi_next (&gsi);
1099 /* Process loops from innermost to outer, stopping at the innermost
1100 loop we unrolled. */
1102 static bool
1103 tree_unroll_loops_completely_1 (bool may_increase_size, bool unroll_outer,
1104 vec<loop_p, va_heap>& father_stack,
1105 struct loop *loop)
1107 struct loop *loop_father;
1108 bool changed = false;
1109 struct loop *inner;
1110 enum unroll_level ul;
1112 /* Process inner loops first. */
1113 for (inner = loop->inner; inner != NULL; inner = inner->next)
1114 changed |= tree_unroll_loops_completely_1 (may_increase_size,
1115 unroll_outer, father_stack,
1116 inner);
1118 /* If we changed an inner loop we cannot process outer loops in this
1119 iteration because SSA form is not up-to-date. Continue with
1120 siblings of outer loops instead. */
1121 if (changed)
1122 return true;
1124 /* Don't unroll #pragma omp simd loops until the vectorizer
1125 attempts to vectorize those. */
1126 if (loop->force_vect)
1127 return false;
1129 /* Try to unroll this loop. */
1130 loop_father = loop_outer (loop);
1131 if (!loop_father)
1132 return false;
1134 if (may_increase_size && optimize_loop_nest_for_speed_p (loop)
1135 /* Unroll outermost loops only if asked to do so or they do
1136 not cause code growth. */
1137 && (unroll_outer || loop_outer (loop_father)))
1138 ul = UL_ALL;
1139 else
1140 ul = UL_NO_GROWTH;
1142 if (canonicalize_loop_induction_variables
1143 (loop, false, ul, !flag_tree_loop_ivcanon))
1145 /* If we'll continue unrolling, we need to propagate constants
1146 within the new basic blocks to fold away induction variable
1147 computations; otherwise, the size might blow up before the
1148 iteration is complete and the IR eventually cleaned up. */
1149 if (loop_outer (loop_father) && !loop_father->aux)
1151 father_stack.safe_push (loop_father);
1152 loop_father->aux = loop_father;
1155 return true;
1158 return false;
1161 /* Unroll LOOPS completely if they iterate just few times. Unless
1162 MAY_INCREASE_SIZE is true, perform the unrolling only if the
1163 size of the code does not increase. */
1165 unsigned int
1166 tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
1168 stack_vec<loop_p, 16> father_stack;
1169 bool changed;
1170 int iteration = 0;
1171 bool irred_invalidated = false;
1175 changed = false;
1176 bitmap loop_closed_ssa_invalidated = NULL;
1178 if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
1179 loop_closed_ssa_invalidated = BITMAP_ALLOC (NULL);
1181 free_numbers_of_iterations_estimates ();
1182 estimate_numbers_of_iterations ();
1184 changed = tree_unroll_loops_completely_1 (may_increase_size,
1185 unroll_outer, father_stack,
1186 current_loops->tree_root);
1187 if (changed)
1189 struct loop **iter;
1190 unsigned i;
1192 /* Be sure to skip unlooped loops while procesing father_stack
1193 array. */
1194 FOR_EACH_VEC_ELT (loops_to_unloop, i, iter)
1195 (*iter)->aux = NULL;
1196 FOR_EACH_VEC_ELT (father_stack, i, iter)
1197 if (!(*iter)->aux)
1198 *iter = NULL;
1199 unloop_loops (loop_closed_ssa_invalidated, &irred_invalidated);
1201 /* We can not use TODO_update_ssa_no_phi because VOPS gets confused. */
1202 if (loop_closed_ssa_invalidated
1203 && !bitmap_empty_p (loop_closed_ssa_invalidated))
1204 rewrite_into_loop_closed_ssa (loop_closed_ssa_invalidated,
1205 TODO_update_ssa);
1206 else
1207 update_ssa (TODO_update_ssa);
1209 /* Propagate the constants within the new basic blocks. */
1210 FOR_EACH_VEC_ELT (father_stack, i, iter)
1211 if (*iter)
1213 unsigned j;
1214 basic_block *body = get_loop_body_in_dom_order (*iter);
1215 for (j = 0; j < (*iter)->num_nodes; j++)
1216 propagate_constants_for_unrolling (body[j]);
1217 free (body);
1218 (*iter)->aux = NULL;
1220 father_stack.truncate (0);
1222 /* This will take care of removing completely unrolled loops
1223 from the loop structures so we can continue unrolling now
1224 innermost loops. */
1225 if (cleanup_tree_cfg ())
1226 update_ssa (TODO_update_ssa_only_virtuals);
1228 /* Clean up the information about numbers of iterations, since
1229 complete unrolling might have invalidated it. */
1230 scev_reset ();
1231 #ifdef ENABLE_CHECKING
1232 if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
1233 verify_loop_closed_ssa (true);
1234 #endif
1236 if (loop_closed_ssa_invalidated)
1237 BITMAP_FREE (loop_closed_ssa_invalidated);
1239 while (changed
1240 && ++iteration <= PARAM_VALUE (PARAM_MAX_UNROLL_ITERATIONS));
1242 father_stack.release ();
1244 if (irred_invalidated
1245 && loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
1246 mark_irreducible_loops ();
1248 return 0;
1251 /* Canonical induction variable creation pass. */
1253 static unsigned int
1254 tree_ssa_loop_ivcanon (void)
1256 if (number_of_loops (cfun) <= 1)
1257 return 0;
1259 return canonicalize_induction_variables ();
1262 static bool
1263 gate_tree_ssa_loop_ivcanon (void)
1265 return flag_tree_loop_ivcanon != 0;
1268 namespace {
1270 const pass_data pass_data_iv_canon =
1272 GIMPLE_PASS, /* type */
1273 "ivcanon", /* name */
1274 OPTGROUP_LOOP, /* optinfo_flags */
1275 true, /* has_gate */
1276 true, /* has_execute */
1277 TV_TREE_LOOP_IVCANON, /* tv_id */
1278 ( PROP_cfg | PROP_ssa ), /* properties_required */
1279 0, /* properties_provided */
1280 0, /* properties_destroyed */
1281 0, /* todo_flags_start */
1282 0, /* todo_flags_finish */
1285 class pass_iv_canon : public gimple_opt_pass
1287 public:
1288 pass_iv_canon (gcc::context *ctxt)
1289 : gimple_opt_pass (pass_data_iv_canon, ctxt)
1292 /* opt_pass methods: */
1293 bool gate () { return gate_tree_ssa_loop_ivcanon (); }
1294 unsigned int execute () { return tree_ssa_loop_ivcanon (); }
1296 }; // class pass_iv_canon
1298 } // anon namespace
1300 gimple_opt_pass *
1301 make_pass_iv_canon (gcc::context *ctxt)
1303 return new pass_iv_canon (ctxt);
1306 /* Complete unrolling of loops. */
1308 static unsigned int
1309 tree_complete_unroll (void)
1311 if (number_of_loops (cfun) <= 1)
1312 return 0;
1314 return tree_unroll_loops_completely (flag_unroll_loops
1315 || flag_peel_loops
1316 || optimize >= 3, true);
1319 static bool
1320 gate_tree_complete_unroll (void)
1322 return true;
1325 namespace {
1327 const pass_data pass_data_complete_unroll =
1329 GIMPLE_PASS, /* type */
1330 "cunroll", /* name */
1331 OPTGROUP_LOOP, /* optinfo_flags */
1332 true, /* has_gate */
1333 true, /* has_execute */
1334 TV_COMPLETE_UNROLL, /* tv_id */
1335 ( PROP_cfg | PROP_ssa ), /* properties_required */
1336 0, /* properties_provided */
1337 0, /* properties_destroyed */
1338 0, /* todo_flags_start */
1339 0, /* todo_flags_finish */
1342 class pass_complete_unroll : public gimple_opt_pass
1344 public:
1345 pass_complete_unroll (gcc::context *ctxt)
1346 : gimple_opt_pass (pass_data_complete_unroll, ctxt)
1349 /* opt_pass methods: */
1350 bool gate () { return gate_tree_complete_unroll (); }
1351 unsigned int execute () { return tree_complete_unroll (); }
1353 }; // class pass_complete_unroll
1355 } // anon namespace
1357 gimple_opt_pass *
1358 make_pass_complete_unroll (gcc::context *ctxt)
1360 return new pass_complete_unroll (ctxt);
1363 /* Complete unrolling of inner loops. */
1365 static unsigned int
1366 tree_complete_unroll_inner (void)
1368 unsigned ret = 0;
1370 loop_optimizer_init (LOOPS_NORMAL
1371 | LOOPS_HAVE_RECORDED_EXITS);
1372 if (number_of_loops (cfun) > 1)
1374 scev_initialize ();
1375 ret = tree_unroll_loops_completely (optimize >= 3, false);
1376 free_numbers_of_iterations_estimates ();
1377 scev_finalize ();
1379 loop_optimizer_finalize ();
1381 return ret;
1384 static bool
1385 gate_tree_complete_unroll_inner (void)
1387 return optimize >= 2;
1390 namespace {
1392 const pass_data pass_data_complete_unrolli =
1394 GIMPLE_PASS, /* type */
1395 "cunrolli", /* name */
1396 OPTGROUP_LOOP, /* optinfo_flags */
1397 true, /* has_gate */
1398 true, /* has_execute */
1399 TV_COMPLETE_UNROLL, /* tv_id */
1400 ( PROP_cfg | PROP_ssa ), /* properties_required */
1401 0, /* properties_provided */
1402 0, /* properties_destroyed */
1403 0, /* todo_flags_start */
1404 TODO_verify_flow, /* todo_flags_finish */
1407 class pass_complete_unrolli : public gimple_opt_pass
1409 public:
1410 pass_complete_unrolli (gcc::context *ctxt)
1411 : gimple_opt_pass (pass_data_complete_unrolli, ctxt)
1414 /* opt_pass methods: */
1415 bool gate () { return gate_tree_complete_unroll_inner (); }
1416 unsigned int execute () { return tree_complete_unroll_inner (); }
1418 }; // class pass_complete_unrolli
1420 } // anon namespace
1422 gimple_opt_pass *
1423 make_pass_complete_unrolli (gcc::context *ctxt)
1425 return new pass_complete_unrolli (ctxt);