1 /* Code sinking for trees
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 Contributed by Daniel Berlin <dan@dberlin.org>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
28 #include "tree-pass.h"
30 #include "gimple-pretty-print.h"
31 #include "fold-const.h"
32 #include "stor-layout.h"
34 #include "gimple-iterator.h"
40 1. Sinking store only using scalar promotion (IE without moving the RHS):
60 Store copy propagation will take care of the store elimination above.
63 2. Sinking using Partial Dead Code Elimination. */
68 /* The number of statements sunk down the flowgraph by code sinking. */
71 /* The number of stores commoned and sunk down by store commoning. */
76 /* Given a PHI, and one of its arguments (DEF), find the edge for
77 that argument and return it. If the argument occurs twice in the PHI node,
81 find_bb_for_arg (gphi
*phi
, tree def
)
84 bool foundone
= false;
85 basic_block result
= NULL
;
86 for (i
= 0; i
< gimple_phi_num_args (phi
); i
++)
87 if (PHI_ARG_DEF (phi
, i
) == def
)
92 result
= gimple_phi_arg_edge (phi
, i
)->src
;
97 /* When the first immediate use is in a statement, then return true if all
98 immediate uses in IMM are in the same statement.
99 We could also do the case where the first immediate use is in a phi node,
100 and all the other uses are in phis in the same basic block, but this
101 requires some expensive checking later (you have to make sure no def/vdef
102 in the statement occurs for multiple edges in the various phi nodes it's
103 used in, so that you only have one place you can sink it to. */
106 all_immediate_uses_same_place (def_operand_p def_p
)
108 tree var
= DEF_FROM_PTR (def_p
);
109 imm_use_iterator imm_iter
;
112 gimple
*firstuse
= NULL
;
113 FOR_EACH_IMM_USE_FAST (use_p
, imm_iter
, var
)
115 if (is_gimple_debug (USE_STMT (use_p
)))
117 if (firstuse
== NULL
)
118 firstuse
= USE_STMT (use_p
);
120 if (firstuse
!= USE_STMT (use_p
))
127 /* Find the nearest common dominator of all of the immediate uses in IMM. */
130 nearest_common_dominator_of_uses (def_operand_p def_p
, bool *debug_stmts
)
132 tree var
= DEF_FROM_PTR (def_p
);
134 basic_block commondom
;
137 imm_use_iterator imm_iter
;
140 FOR_EACH_IMM_USE_FAST (use_p
, imm_iter
, var
)
142 gimple
*usestmt
= USE_STMT (use_p
);
143 basic_block useblock
;
145 if (gphi
*phi
= dyn_cast
<gphi
*> (usestmt
))
147 int idx
= PHI_ARG_INDEX_FROM_USE (use_p
);
149 useblock
= gimple_phi_arg_edge (phi
, idx
)->src
;
151 else if (is_gimple_debug (usestmt
))
158 useblock
= gimple_bb (usestmt
);
161 /* Short circuit. Nothing dominates the entry block. */
162 if (useblock
== ENTRY_BLOCK_PTR_FOR_FN (cfun
))
165 bitmap_set_bit (blocks
, useblock
->index
);
167 commondom
= BASIC_BLOCK_FOR_FN (cfun
, bitmap_first_set_bit (blocks
));
168 EXECUTE_IF_SET_IN_BITMAP (blocks
, 0, j
, bi
)
169 commondom
= nearest_common_dominator (CDI_DOMINATORS
, commondom
,
170 BASIC_BLOCK_FOR_FN (cfun
, j
));
174 /* Given EARLY_BB and LATE_BB, two blocks in a path through the dominator
175 tree, return the best basic block between them (inclusive) to place
178 We want the most control dependent block in the shallowest loop nest.
180 If the resulting block is in a shallower loop nest, then use it. Else
181 only use the resulting block if it has significantly lower execution
182 frequency than EARLY_BB to avoid gratuitous statement movement. We
183 consider statements with VOPS more desirable to move.
185 This pass would obviously benefit from PDO as it utilizes block
186 frequencies. It would also benefit from recomputing frequencies
187 if profile data is not available since frequencies often get out
188 of sync with reality. */
191 select_best_block (basic_block early_bb
,
195 basic_block best_bb
= late_bb
;
196 basic_block temp_bb
= late_bb
;
199 while (temp_bb
!= early_bb
)
201 /* If we've moved into a lower loop nest, then that becomes
203 if (bb_loop_depth (temp_bb
) < bb_loop_depth (best_bb
))
206 /* Walk up the dominator tree, hopefully we'll find a shallower
208 temp_bb
= get_immediate_dominator (CDI_DOMINATORS
, temp_bb
);
211 /* Placing a statement before a setjmp-like function would be invalid
212 (it cannot be reevaluated when execution follows an abnormal edge).
213 If we selected a block with abnormal predecessors, just punt. */
214 if (bb_has_abnormal_pred (best_bb
))
217 /* If we found a shallower loop nest, then we always consider that
218 a win. This will always give us the most control dependent block
219 within that loop nest. */
220 if (bb_loop_depth (best_bb
) < bb_loop_depth (early_bb
))
223 /* Get the sinking threshold. If the statement to be moved has memory
224 operands, then increase the threshold by 7% as those are even more
225 profitable to avoid, clamping at 100%. */
226 threshold
= param_sink_frequency_threshold
;
227 if (gimple_vuse (stmt
) || gimple_vdef (stmt
))
234 /* If BEST_BB is at the same nesting level, then require it to have
235 significantly lower execution frequency to avoid gratuitous movement. */
236 if (bb_loop_depth (best_bb
) == bb_loop_depth (early_bb
)
237 /* If result of comparsion is unknown, prefer EARLY_BB.
238 Thus use !(...>=..) rather than (...<...) */
239 && !(best_bb
->count
* 100 >= early_bb
->count
* threshold
))
242 /* No better block found, so return EARLY_BB, which happens to be the
243 statement's original block. */
247 /* Given a statement (STMT) and the basic block it is currently in (FROMBB),
248 determine the location to sink the statement to, if any.
249 Returns true if there is such location; in that case, TOGSI points to the
250 statement before that STMT should be moved. */
253 statement_sink_location (gimple
*stmt
, basic_block frombb
,
254 gimple_stmt_iterator
*togsi
, bool *zero_uses_p
)
257 use_operand_p one_use
= NULL_USE_OPERAND_P
;
262 imm_use_iterator imm_iter
;
264 *zero_uses_p
= false;
266 /* We only can sink assignments and const/pure calls that are guaranteed
267 to return exactly once. */
269 if (!is_gimple_assign (stmt
)
270 && (!is_gimple_call (stmt
)
271 || !((cf
= gimple_call_flags (stmt
)) & (ECF_CONST
|ECF_PURE
))
272 || (cf
& (ECF_LOOPING_CONST_OR_PURE
|ECF_RETURNS_TWICE
))))
275 /* We only can sink stmts with a single definition. */
276 def_p
= single_ssa_def_operand (stmt
, SSA_OP_ALL_DEFS
);
277 if (def_p
== NULL_DEF_OPERAND_P
)
280 /* There are a few classes of things we can't or don't move, some because we
281 don't have code to handle it, some because it's not profitable and some
282 because it's not legal.
284 We can't sink things that may be global stores, at least not without
285 calculating a lot more information, because we may cause it to no longer
286 be seen by an external routine that needs it depending on where it gets
289 We can't sink statements that end basic blocks without splitting the
290 incoming edge for the sink location to place it there.
292 We can't sink statements that have volatile operands.
294 We don't want to sink dead code, so anything with 0 immediate uses is not
297 Don't sink BLKmode assignments if current function has any local explicit
298 register variables, as BLKmode assignments may involve memcpy or memset
299 calls or, on some targets, inline expansion thereof that sometimes need
300 to use specific hard registers.
303 if (stmt_ends_bb_p (stmt
)
304 || gimple_has_side_effects (stmt
)
305 || (cfun
->has_local_explicit_reg_vars
306 && TYPE_MODE (TREE_TYPE (gimple_get_lhs (stmt
))) == BLKmode
))
309 /* Return if there are no immediate uses of this stmt. */
310 if (has_zero_uses (DEF_FROM_PTR (def_p
)))
316 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (DEF_FROM_PTR (def_p
)))
319 FOR_EACH_SSA_USE_OPERAND (use_p
, stmt
, iter
, SSA_OP_ALL_USES
)
321 tree use
= USE_FROM_PTR (use_p
);
322 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (use
))
328 /* If stmt is a store the one and only use needs to be the VOP
330 if (virtual_operand_p (DEF_FROM_PTR (def_p
)))
332 FOR_EACH_IMM_USE_FAST (use_p
, imm_iter
, DEF_FROM_PTR (def_p
))
334 gimple
*use_stmt
= USE_STMT (use_p
);
336 /* A killing definition is not a use. */
337 if ((gimple_has_lhs (use_stmt
)
338 && operand_equal_p (gimple_get_lhs (stmt
),
339 gimple_get_lhs (use_stmt
), 0))
340 || stmt_kills_ref_p (use_stmt
, gimple_get_lhs (stmt
)))
342 /* If use_stmt is or might be a nop assignment then USE_STMT
343 acts as a use as well as definition. */
345 && ref_maybe_used_by_stmt_p (use_stmt
,
346 gimple_get_lhs (stmt
)))
351 if (gimple_code (use_stmt
) != GIMPLE_PHI
)
363 /* If all the immediate uses are not in the same place, find the nearest
364 common dominator of all the immediate uses. For PHI nodes, we have to
365 find the nearest common dominator of all of the predecessor blocks, since
366 that is where insertion would have to take place. */
367 else if (gimple_vuse (stmt
)
368 || !all_immediate_uses_same_place (def_p
))
370 bool debug_stmts
= false;
371 basic_block commondom
= nearest_common_dominator_of_uses (def_p
,
374 if (commondom
== frombb
)
377 /* If this is a load then do not sink past any stores.
378 Look for virtual definitions in the path from frombb to the sink
379 location computed from the real uses and if found, adjust
380 that it a common dominator. */
381 if (gimple_vuse (stmt
))
383 /* Do not sink loads from hard registers. */
384 if (gimple_assign_single_p (stmt
)
385 && TREE_CODE (gimple_assign_rhs1 (stmt
)) == VAR_DECL
386 && DECL_HARD_REGISTER (gimple_assign_rhs1 (stmt
)))
389 imm_use_iterator imm_iter
;
391 FOR_EACH_IMM_USE_FAST (use_p
, imm_iter
, gimple_vuse (stmt
))
393 gimple
*use_stmt
= USE_STMT (use_p
);
394 basic_block bb
= gimple_bb (use_stmt
);
395 /* For PHI nodes the block we know sth about is the incoming block
397 if (gimple_code (use_stmt
) == GIMPLE_PHI
)
399 /* If the PHI defines the virtual operand, ignore it. */
400 if (gimple_phi_result (use_stmt
) == gimple_vuse (stmt
))
402 /* In case the PHI node post-dominates the current insert
403 location we can disregard it. But make sure it is not
404 dominating it as well as can happen in a CFG cycle. */
406 && !dominated_by_p (CDI_DOMINATORS
, commondom
, bb
)
407 && dominated_by_p (CDI_POST_DOMINATORS
, commondom
, bb
)
408 /* If the blocks are possibly within the same irreducible
409 cycle the above check breaks down. */
410 && !((bb
->flags
& commondom
->flags
& BB_IRREDUCIBLE_LOOP
)
411 && bb
->loop_father
== commondom
->loop_father
)
412 && !((commondom
->flags
& BB_IRREDUCIBLE_LOOP
)
413 && flow_loop_nested_p (commondom
->loop_father
,
415 && !((bb
->flags
& BB_IRREDUCIBLE_LOOP
)
416 && flow_loop_nested_p (bb
->loop_father
,
417 commondom
->loop_father
)))
419 bb
= EDGE_PRED (bb
, PHI_ARG_INDEX_FROM_USE (use_p
))->src
;
421 else if (!gimple_vdef (use_stmt
))
423 /* If the use is not dominated by the path entry it is not on
425 if (!dominated_by_p (CDI_DOMINATORS
, bb
, frombb
))
427 /* There is no easy way to disregard defs not on the path from
428 frombb to commondom so just consider them all. */
429 commondom
= nearest_common_dominator (CDI_DOMINATORS
,
431 if (commondom
== frombb
)
436 /* Our common dominator has to be dominated by frombb in order to be a
437 trivially safe place to put this statement, since it has multiple
439 if (!dominated_by_p (CDI_DOMINATORS
, commondom
, frombb
))
442 commondom
= select_best_block (frombb
, commondom
, stmt
);
444 if (commondom
== frombb
)
447 *togsi
= gsi_after_labels (commondom
);
453 FOR_EACH_IMM_USE_FAST (one_use
, imm_iter
, DEF_FROM_PTR (def_p
))
455 if (is_gimple_debug (USE_STMT (one_use
)))
459 use
= USE_STMT (one_use
);
461 if (gimple_code (use
) != GIMPLE_PHI
)
463 sinkbb
= select_best_block (frombb
, gimple_bb (use
), stmt
);
465 if (sinkbb
== frombb
)
468 if (sinkbb
== gimple_bb (use
))
469 *togsi
= gsi_for_stmt (use
);
471 *togsi
= gsi_after_labels (sinkbb
);
477 sinkbb
= find_bb_for_arg (as_a
<gphi
*> (use
), DEF_FROM_PTR (def_p
));
479 /* This can happen if there are multiple uses in a PHI. */
483 sinkbb
= select_best_block (frombb
, sinkbb
, stmt
);
484 if (!sinkbb
|| sinkbb
== frombb
)
487 /* If the latch block is empty, don't make it non-empty by sinking
488 something into it. */
489 if (sinkbb
== frombb
->loop_father
->latch
490 && empty_block_p (sinkbb
))
493 *togsi
= gsi_after_labels (sinkbb
);
498 /* Very simplistic code to sink common stores from the predecessor through
499 our virtual PHI. We do this before sinking stmts from BB as it might
500 expose sinking opportunities of the merged stores.
501 Once we have partial dead code elimination through sth like SSU-PRE this
502 should be moved there. */
505 sink_common_stores_to_bb (basic_block bb
)
510 if (EDGE_COUNT (bb
->preds
) > 1
511 && (phi
= get_virtual_phi (bb
)))
513 /* Repeat until no more common stores are found. */
516 gimple
*first_store
= NULL
;
517 auto_vec
<tree
, 5> vdefs
;
518 gimple_stmt_iterator gsi
;
520 /* Search for common stores defined by all virtual PHI args.
521 ??? Common stores not present in all predecessors could
522 be handled by inserting a forwarder to sink to. Generally
523 this involves deciding which stores to do this for if
524 multiple common stores are present for different sets of
525 predecessors. See PR11832 for an interesting case. */
526 for (unsigned i
= 0; i
< gimple_phi_num_args (phi
); ++i
)
528 tree arg
= gimple_phi_arg_def (phi
, i
);
529 gimple
*def
= SSA_NAME_DEF_STMT (arg
);
530 if (! is_gimple_assign (def
)
531 || stmt_can_throw_internal (cfun
, def
)
532 || (gimple_phi_arg_edge (phi
, i
)->flags
& EDGE_ABNORMAL
))
534 /* ??? We could handle some cascading with the def being
535 another PHI. We'd have to insert multiple PHIs for
536 the rhs then though (if they are not all equal). */
540 /* ??? Do not try to do anything fancy with aliasing, thus
541 do not sink across non-aliased loads (or even stores,
542 so different store order will make the sinking fail). */
543 bool all_uses_on_phi
= true;
544 imm_use_iterator iter
;
546 FOR_EACH_IMM_USE_FAST (use_p
, iter
, arg
)
547 if (USE_STMT (use_p
) != phi
)
549 all_uses_on_phi
= false;
552 if (! all_uses_on_phi
)
557 /* Check all stores are to the same LHS. */
560 /* ??? We could handle differing SSA uses in the LHS by inserting
562 else if (! operand_equal_p (gimple_assign_lhs (first_store
),
563 gimple_assign_lhs (def
), 0)
564 || (gimple_clobber_p (first_store
)
565 != gimple_clobber_p (def
)))
570 vdefs
.safe_push (arg
);
575 /* Check if we need a PHI node to merge the stored values. */
577 if (!gimple_clobber_p (first_store
))
578 for (unsigned i
= 1; i
< vdefs
.length (); ++i
)
580 gimple
*def
= SSA_NAME_DEF_STMT (vdefs
[i
]);
581 if (! operand_equal_p (gimple_assign_rhs1 (first_store
),
582 gimple_assign_rhs1 (def
), 0))
589 /* We cannot handle aggregate values if we need to merge them. */
590 tree type
= TREE_TYPE (gimple_assign_lhs (first_store
));
592 && ! is_gimple_reg_type (type
))
595 if (dump_enabled_p ())
597 dump_printf_loc (MSG_OPTIMIZED_LOCATIONS
,
599 "sinking common stores %sto ",
600 allsame
? "with same value " : "");
601 dump_generic_expr (MSG_OPTIMIZED_LOCATIONS
, TDF_SLIM
,
602 gimple_assign_lhs (first_store
));
603 dump_printf (MSG_OPTIMIZED_LOCATIONS
, "\n");
606 /* Insert a PHI to merge differing stored values if necessary.
607 Note that in general inserting PHIs isn't a very good idea as
608 it makes the job of coalescing and register allocation harder.
609 Even common SSA uses on the rhs/lhs might extend their lifetime
610 across multiple edges by this code motion which makes
611 register allocation harder. */
615 from
= make_ssa_name (type
);
616 gphi
*newphi
= create_phi_node (from
, bb
);
617 for (unsigned i
= 0; i
< vdefs
.length (); ++i
)
619 gimple
*def
= SSA_NAME_DEF_STMT (vdefs
[i
]);
620 add_phi_arg (newphi
, gimple_assign_rhs1 (def
),
621 EDGE_PRED (bb
, i
), UNKNOWN_LOCATION
);
625 from
= gimple_assign_rhs1 (first_store
);
627 /* Remove all stores. */
628 for (unsigned i
= 0; i
< vdefs
.length (); ++i
)
629 TREE_VISITED (vdefs
[i
]) = 1;
630 for (unsigned i
= 0; i
< vdefs
.length (); ++i
)
631 /* If we have more than one use of a VDEF on the PHI make sure
632 we remove the defining stmt only once. */
633 if (TREE_VISITED (vdefs
[i
]))
635 TREE_VISITED (vdefs
[i
]) = 0;
636 gimple
*def
= SSA_NAME_DEF_STMT (vdefs
[i
]);
637 gsi
= gsi_for_stmt (def
);
638 unlink_stmt_vdef (def
);
639 gsi_remove (&gsi
, true);
643 /* Insert the first store at the beginning of the merge BB. */
644 gimple_set_vdef (first_store
, gimple_phi_result (phi
));
645 SSA_NAME_DEF_STMT (gimple_vdef (first_store
)) = first_store
;
646 gimple_phi_set_result (phi
, make_ssa_name (gimple_vop (cfun
)));
647 gimple_set_vuse (first_store
, gimple_phi_result (phi
));
648 gimple_assign_set_rhs1 (first_store
, from
);
649 /* ??? Should we reset first_stores location? */
650 gsi
= gsi_after_labels (bb
);
651 gsi_insert_before (&gsi
, first_store
, GSI_SAME_STMT
);
652 sink_stats
.commoned
++;
654 todo
|= TODO_cleanup_cfg
;
657 /* We could now have empty predecessors that we could remove,
658 forming a proper CFG for further sinking. Note that even
659 CFG cleanup doesn't do this fully at the moment and it
660 doesn't preserve post-dominators in the process either.
661 The mergephi pass might do it though. gcc.dg/tree-ssa/ssa-sink-13.c
662 shows this nicely if you disable tail merging or (same effect)
663 make the stored values unequal. */
669 /* Perform code sinking on BB */
672 sink_code_in_bb (basic_block bb
)
675 gimple_stmt_iterator gsi
;
681 /* Sink common stores from the predecessor through our virtual PHI. */
682 todo
|= sink_common_stores_to_bb (bb
);
684 /* If this block doesn't dominate anything, there can't be any place to sink
685 the statements to. */
686 if (first_dom_son (CDI_DOMINATORS
, bb
) == NULL
)
689 /* We can't move things across abnormal edges, so don't try. */
690 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
691 if (e
->flags
& EDGE_ABNORMAL
)
694 for (gsi
= gsi_last_bb (bb
); !gsi_end_p (gsi
);)
696 gimple
*stmt
= gsi_stmt (gsi
);
697 gimple_stmt_iterator togsi
;
700 if (!statement_sink_location (stmt
, bb
, &togsi
, &zero_uses_p
))
702 gimple_stmt_iterator saved
= gsi
;
703 if (!gsi_end_p (gsi
))
705 /* If we face a dead stmt remove it as it possibly blocks
708 && !gimple_vdef (stmt
)
709 && (cfun
->can_delete_dead_exceptions
710 || !stmt_could_throw_p (cfun
, stmt
)))
712 gsi_remove (&saved
, true);
721 fprintf (dump_file
, "Sinking ");
722 print_gimple_stmt (dump_file
, stmt
, 0, TDF_VOPS
);
723 fprintf (dump_file
, " from bb %d to bb %d\n",
724 bb
->index
, (gsi_bb (togsi
))->index
);
727 /* Update virtual operands of statements in the path we
729 if (gimple_vdef (stmt
))
731 imm_use_iterator iter
;
735 FOR_EACH_IMM_USE_STMT (vuse_stmt
, iter
, gimple_vdef (stmt
))
736 if (gimple_code (vuse_stmt
) != GIMPLE_PHI
)
737 FOR_EACH_IMM_USE_ON_STMT (use_p
, iter
)
738 SET_USE (use_p
, gimple_vuse (stmt
));
741 /* If this is the end of the basic block, we need to insert at the end
742 of the basic block. */
743 if (gsi_end_p (togsi
))
744 gsi_move_to_bb_end (&gsi
, gsi_bb (togsi
));
746 gsi_move_before (&gsi
, &togsi
);
750 /* If we've just removed the last statement of the BB, the
751 gsi_end_p() test below would fail, but gsi_prev() would have
752 succeeded, and we want it to succeed. So we keep track of
753 whether we're at the last statement and pick up the new last
757 gsi
= gsi_last_bb (bb
);
762 if (!gsi_end_p (gsi
))
767 for (son
= first_dom_son (CDI_POST_DOMINATORS
, bb
);
769 son
= next_dom_son (CDI_POST_DOMINATORS
, son
))
771 todo
|= sink_code_in_bb (son
);
777 /* Perform code sinking.
778 This moves code down the flowgraph when we know it would be
779 profitable to do so, or it wouldn't increase the number of
780 executions of the statement.
793 a_6 = PHI (a_5, a_1);
796 we'll transform this into:
807 a_6 = PHI (a_5, a_1);
810 Note that this reduces the number of computations of a = b + c to 1
811 when we take the else edge, instead of 2.
815 const pass_data pass_data_sink_code
=
817 GIMPLE_PASS
, /* type */
819 OPTGROUP_NONE
, /* optinfo_flags */
820 TV_TREE_SINK
, /* tv_id */
821 /* PROP_no_crit_edges is ensured by running split_edges_for_insertion in
822 pass_data_sink_code::execute (). */
823 ( PROP_cfg
| PROP_ssa
), /* properties_required */
824 0, /* properties_provided */
825 0, /* properties_destroyed */
826 0, /* todo_flags_start */
827 TODO_update_ssa
, /* todo_flags_finish */
830 class pass_sink_code
: public gimple_opt_pass
833 pass_sink_code (gcc::context
*ctxt
)
834 : gimple_opt_pass (pass_data_sink_code
, ctxt
), unsplit_edges (false)
837 /* opt_pass methods: */
838 bool gate (function
*) final override
{ return flag_tree_sink
!= 0; }
839 unsigned int execute (function
*) final override
;
840 opt_pass
*clone (void) final override
{ return new pass_sink_code (m_ctxt
); }
841 void set_pass_param (unsigned n
, bool param
) final override
844 unsplit_edges
= param
;
849 }; // class pass_sink_code
852 pass_sink_code::execute (function
*fun
)
854 loop_optimizer_init (LOOPS_NORMAL
);
855 split_edges_for_insertion ();
856 /* Arrange for the critical edge splitting to be undone if requested. */
857 unsigned todo
= unsplit_edges
? TODO_cleanup_cfg
: 0;
858 connect_infinite_loops_to_exit ();
859 memset (&sink_stats
, 0, sizeof (sink_stats
));
860 calculate_dominance_info (CDI_DOMINATORS
);
861 calculate_dominance_info (CDI_POST_DOMINATORS
);
862 todo
|= sink_code_in_bb (EXIT_BLOCK_PTR_FOR_FN (fun
));
863 statistics_counter_event (fun
, "Sunk statements", sink_stats
.sunk
);
864 statistics_counter_event (fun
, "Commoned stores", sink_stats
.commoned
);
865 free_dominance_info (CDI_POST_DOMINATORS
);
866 remove_fake_exit_edges ();
867 loop_optimizer_finalize ();
875 make_pass_sink_code (gcc::context
*ctxt
)
877 return new pass_sink_code (ctxt
);