1 /* If-conversion for vectorizer.
2 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc.
4 Contributed by Devang Patel <dpatel@apple.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 /* This pass implements a tree level if-conversion of loops. Its
23 initial goal is to help the vectorizer to vectorize loops with
26 A short description of if-conversion:
28 o Decide if a loop is if-convertible or not.
29 o Walk all loop basic blocks in breadth first order (BFS order).
30 o Remove conditional statements (at the end of basic block)
31 and propagate condition into destination basic blocks'
33 o Replace modify expression with conditional modify expression
34 using current basic block's condition.
35 o Merge all basic blocks
36 o Replace phi nodes with conditional modify expr
37 o Merge all basic blocks into header
39 Sample transformation:
44 # i_23 = PHI <0(0), i_18(10)>;
47 if (j_15 > 41) goto <L1>; else goto <L17>;
54 # iftmp.2_4 = PHI <0(8), 42(2)>;
58 if (i_18 <= 15) goto <L19>; else goto <L18>;
68 # i_23 = PHI <0(0), i_18(10)>;
73 iftmp.2_4 = j_15 > 41 ? 42 : 0;
76 if (i_18 <= 15) goto <L19>; else goto <L18>;
86 #include "coretypes.h"
90 #include "basic-block.h"
91 #include "gimple-pretty-print.h"
92 #include "tree-flow.h"
94 #include "tree-chrec.h"
95 #include "tree-data-ref.h"
96 #include "tree-scalar-evolution.h"
97 #include "tree-pass.h"
100 /* List of basic blocks in if-conversion-suitable order. */
101 static basic_block
*ifc_bbs
;
103 /* Structure used to predicate basic blocks. This is attached to the
104 ->aux field of the BBs in the loop to be if-converted. */
105 typedef struct bb_predicate_s
{
107 /* The condition under which this basic block is executed. */
110 /* PREDICATE is gimplified, and the sequence of statements is
111 recorded here, in order to avoid the duplication of computations
112 that occur in previous conditions. See PR44483. */
113 gimple_seq predicate_gimplified_stmts
;
116 /* Returns true when the basic block BB has a predicate. */
119 bb_has_predicate (basic_block bb
)
121 return bb
->aux
!= NULL
;
124 /* Returns the gimplified predicate for basic block BB. */
127 bb_predicate (basic_block bb
)
129 return ((bb_predicate_p
) bb
->aux
)->predicate
;
132 /* Sets the gimplified predicate COND for basic block BB. */
135 set_bb_predicate (basic_block bb
, tree cond
)
137 gcc_assert ((TREE_CODE (cond
) == TRUTH_NOT_EXPR
138 && is_gimple_condexpr (TREE_OPERAND (cond
, 0)))
139 || is_gimple_condexpr (cond
));
140 ((bb_predicate_p
) bb
->aux
)->predicate
= cond
;
143 /* Returns the sequence of statements of the gimplification of the
144 predicate for basic block BB. */
146 static inline gimple_seq
147 bb_predicate_gimplified_stmts (basic_block bb
)
149 return ((bb_predicate_p
) bb
->aux
)->predicate_gimplified_stmts
;
152 /* Sets the sequence of statements STMTS of the gimplification of the
153 predicate for basic block BB. */
156 set_bb_predicate_gimplified_stmts (basic_block bb
, gimple_seq stmts
)
158 ((bb_predicate_p
) bb
->aux
)->predicate_gimplified_stmts
= stmts
;
161 /* Adds the sequence of statements STMTS to the sequence of statements
162 of the predicate for basic block BB. */
165 add_bb_predicate_gimplified_stmts (basic_block bb
, gimple_seq stmts
)
168 (&(((bb_predicate_p
) bb
->aux
)->predicate_gimplified_stmts
), stmts
);
171 /* Initializes to TRUE the predicate of basic block BB. */
174 init_bb_predicate (basic_block bb
)
176 bb
->aux
= XNEW (struct bb_predicate_s
);
177 set_bb_predicate_gimplified_stmts (bb
, NULL
);
178 set_bb_predicate (bb
, boolean_true_node
);
181 /* Free the predicate of basic block BB. */
184 free_bb_predicate (basic_block bb
)
188 if (!bb_has_predicate (bb
))
191 /* Release the SSA_NAMEs created for the gimplification of the
193 stmts
= bb_predicate_gimplified_stmts (bb
);
196 gimple_stmt_iterator i
;
198 for (i
= gsi_start (stmts
); !gsi_end_p (i
); gsi_next (&i
))
199 free_stmt_operands (gsi_stmt (i
));
206 /* Free the predicate of BB and reinitialize it with the true
210 reset_bb_predicate (basic_block bb
)
212 free_bb_predicate (bb
);
213 init_bb_predicate (bb
);
216 /* Returns a new SSA_NAME of type TYPE that is assigned the value of
217 the expression EXPR. Inserts the statement created for this
218 computation before GSI and leaves the iterator GSI at the same
222 ifc_temp_var (tree type
, tree expr
, gimple_stmt_iterator
*gsi
)
224 const char *name
= "_ifc_";
228 /* Create new temporary variable. */
229 var
= create_tmp_var (type
, name
);
230 add_referenced_var (var
);
232 /* Build new statement to assign EXPR to new variable. */
233 stmt
= gimple_build_assign (var
, expr
);
235 /* Get SSA name for the new variable and set make new statement
236 its definition statement. */
237 new_name
= make_ssa_name (var
, stmt
);
238 gimple_assign_set_lhs (stmt
, new_name
);
239 SSA_NAME_DEF_STMT (new_name
) = stmt
;
242 gsi_insert_before (gsi
, stmt
, GSI_SAME_STMT
);
243 return gimple_assign_lhs (stmt
);
246 /* Return true when COND is a true predicate. */
249 is_true_predicate (tree cond
)
251 return (cond
== NULL_TREE
252 || cond
== boolean_true_node
253 || integer_onep (cond
));
256 /* Returns true when BB has a predicate that is not trivial: true or
260 is_predicated (basic_block bb
)
262 return !is_true_predicate (bb_predicate (bb
));
265 /* Parses the predicate COND and returns its comparison code and
266 operands OP0 and OP1. */
268 static enum tree_code
269 parse_predicate (tree cond
, tree
*op0
, tree
*op1
)
273 if (TREE_CODE (cond
) == SSA_NAME
274 && is_gimple_assign (s
= SSA_NAME_DEF_STMT (cond
)))
276 if (TREE_CODE_CLASS (gimple_assign_rhs_code (s
)) == tcc_comparison
)
278 *op0
= gimple_assign_rhs1 (s
);
279 *op1
= gimple_assign_rhs2 (s
);
280 return gimple_assign_rhs_code (s
);
283 else if (gimple_assign_rhs_code (s
) == TRUTH_NOT_EXPR
)
285 tree op
= gimple_assign_rhs1 (s
);
286 tree type
= TREE_TYPE (op
);
287 enum tree_code code
= parse_predicate (op
, op0
, op1
);
289 return code
== ERROR_MARK
? ERROR_MARK
290 : invert_tree_comparison (code
, HONOR_NANS (TYPE_MODE (type
)));
296 if (TREE_CODE_CLASS (TREE_CODE (cond
)) == tcc_comparison
)
298 *op0
= TREE_OPERAND (cond
, 0);
299 *op1
= TREE_OPERAND (cond
, 1);
300 return TREE_CODE (cond
);
306 /* Returns the fold of predicate C1 OR C2 at location LOC. */
309 fold_or_predicates (location_t loc
, tree c1
, tree c2
)
311 tree op1a
, op1b
, op2a
, op2b
;
312 enum tree_code code1
= parse_predicate (c1
, &op1a
, &op1b
);
313 enum tree_code code2
= parse_predicate (c2
, &op2a
, &op2b
);
315 if (code1
!= ERROR_MARK
&& code2
!= ERROR_MARK
)
317 tree t
= maybe_fold_or_comparisons (code1
, op1a
, op1b
,
323 return fold_build2_loc (loc
, TRUTH_OR_EXPR
, boolean_type_node
, c1
, c2
);
326 /* Add condition NC to the predicate list of basic block BB. */
329 add_to_predicate_list (basic_block bb
, tree nc
)
333 if (is_true_predicate (nc
))
336 if (!is_predicated (bb
))
340 bc
= bb_predicate (bb
);
341 bc
= fold_or_predicates (EXPR_LOCATION (bc
), nc
, bc
);
342 if (is_true_predicate (bc
))
344 reset_bb_predicate (bb
);
349 /* Allow a TRUTH_NOT_EXPR around the main predicate. */
350 if (TREE_CODE (bc
) == TRUTH_NOT_EXPR
)
351 tp
= &TREE_OPERAND (bc
, 0);
354 if (!is_gimple_condexpr (*tp
))
357 *tp
= force_gimple_operand_1 (*tp
, &stmts
, is_gimple_condexpr
, NULL_TREE
);
358 add_bb_predicate_gimplified_stmts (bb
, stmts
);
360 set_bb_predicate (bb
, bc
);
363 /* Add the condition COND to the previous condition PREV_COND, and add
364 this to the predicate list of the destination of edge E. LOOP is
365 the loop to be if-converted. */
368 add_to_dst_predicate_list (struct loop
*loop
, edge e
,
369 tree prev_cond
, tree cond
)
371 if (!flow_bb_inside_loop_p (loop
, e
->dest
))
374 if (!is_true_predicate (prev_cond
))
375 cond
= fold_build2 (TRUTH_AND_EXPR
, boolean_type_node
,
378 add_to_predicate_list (e
->dest
, cond
);
381 /* Return true if one of the successor edges of BB exits LOOP. */
384 bb_with_exit_edge_p (struct loop
*loop
, basic_block bb
)
389 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
390 if (loop_exit_edge_p (loop
, e
))
396 /* Return true when PHI is if-convertible. PHI is part of loop LOOP
397 and it belongs to basic block BB.
399 PHI is not if-convertible if:
400 - it has more than 2 arguments.
402 When the flag_tree_loop_if_convert_stores is not set, PHI is not
404 - a virtual PHI is immediately used in another PHI node,
405 - there is a virtual PHI in a BB other than the loop->header. */
408 if_convertible_phi_p (struct loop
*loop
, basic_block bb
, gimple phi
)
410 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
412 fprintf (dump_file
, "-------------------------\n");
413 print_gimple_stmt (dump_file
, phi
, 0, TDF_SLIM
);
416 if (bb
!= loop
->header
&& gimple_phi_num_args (phi
) != 2)
418 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
419 fprintf (dump_file
, "More than two phi node args.\n");
423 if (flag_tree_loop_if_convert_stores
)
426 /* When the flag_tree_loop_if_convert_stores is not set, check
427 that there are no memory writes in the branches of the loop to be
429 if (!is_gimple_reg (SSA_NAME_VAR (gimple_phi_result (phi
))))
431 imm_use_iterator imm_iter
;
434 if (bb
!= loop
->header
)
436 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
437 fprintf (dump_file
, "Virtual phi not on loop->header.\n");
441 FOR_EACH_IMM_USE_FAST (use_p
, imm_iter
, gimple_phi_result (phi
))
443 if (gimple_code (USE_STMT (use_p
)) == GIMPLE_PHI
)
445 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
446 fprintf (dump_file
, "Difficult to handle this virtual phi.\n");
455 /* Records the status of a data reference. This struct is attached to
456 each DR->aux field. */
459 /* -1 when not initialized, 0 when false, 1 when true. */
460 int written_at_least_once
;
462 /* -1 when not initialized, 0 when false, 1 when true. */
463 int rw_unconditionally
;
466 #define IFC_DR(DR) ((struct ifc_dr *) (DR)->aux)
467 #define DR_WRITTEN_AT_LEAST_ONCE(DR) (IFC_DR (DR)->written_at_least_once)
468 #define DR_RW_UNCONDITIONALLY(DR) (IFC_DR (DR)->rw_unconditionally)
470 /* Returns true when the memory references of STMT are read or written
471 unconditionally. In other words, this function returns true when
472 for every data reference A in STMT there exist other accesses to
473 a data reference with the same base with predicates that add up (OR-up) to
474 the true predicate: this ensures that the data reference A is touched
475 (read or written) on every iteration of the if-converted loop. */
478 memrefs_read_or_written_unconditionally (gimple stmt
,
479 VEC (data_reference_p
, heap
) *drs
)
482 data_reference_p a
, b
;
483 tree ca
= bb_predicate (gimple_bb (stmt
));
485 for (i
= 0; VEC_iterate (data_reference_p
, drs
, i
, a
); i
++)
486 if (DR_STMT (a
) == stmt
)
489 int x
= DR_RW_UNCONDITIONALLY (a
);
497 for (j
= 0; VEC_iterate (data_reference_p
, drs
, j
, b
); j
++)
499 tree ref_base_a
= DR_REF (a
);
500 tree ref_base_b
= DR_REF (b
);
502 if (DR_STMT (b
) == stmt
)
505 while (TREE_CODE (ref_base_a
) == COMPONENT_REF
506 || TREE_CODE (ref_base_a
) == IMAGPART_EXPR
507 || TREE_CODE (ref_base_a
) == REALPART_EXPR
)
508 ref_base_a
= TREE_OPERAND (ref_base_a
, 0);
510 while (TREE_CODE (ref_base_b
) == COMPONENT_REF
511 || TREE_CODE (ref_base_b
) == IMAGPART_EXPR
512 || TREE_CODE (ref_base_b
) == REALPART_EXPR
)
513 ref_base_b
= TREE_OPERAND (ref_base_b
, 0);
515 if (!operand_equal_p (ref_base_a
, ref_base_b
, 0))
517 tree cb
= bb_predicate (gimple_bb (DR_STMT (b
)));
519 if (DR_RW_UNCONDITIONALLY (b
) == 1
520 || is_true_predicate (cb
)
521 || is_true_predicate (ca
522 = fold_or_predicates (EXPR_LOCATION (cb
), ca
, cb
)))
524 DR_RW_UNCONDITIONALLY (a
) = 1;
525 DR_RW_UNCONDITIONALLY (b
) = 1;
534 DR_RW_UNCONDITIONALLY (a
) = 0;
542 /* Returns true when the memory references of STMT are unconditionally
543 written. In other words, this function returns true when for every
544 data reference A written in STMT, there exist other writes to the
545 same data reference with predicates that add up (OR-up) to the true
546 predicate: this ensures that the data reference A is written on
547 every iteration of the if-converted loop. */
550 write_memrefs_written_at_least_once (gimple stmt
,
551 VEC (data_reference_p
, heap
) *drs
)
554 data_reference_p a
, b
;
555 tree ca
= bb_predicate (gimple_bb (stmt
));
557 for (i
= 0; VEC_iterate (data_reference_p
, drs
, i
, a
); i
++)
558 if (DR_STMT (a
) == stmt
562 int x
= DR_WRITTEN_AT_LEAST_ONCE (a
);
570 for (j
= 0; VEC_iterate (data_reference_p
, drs
, j
, b
); j
++)
571 if (DR_STMT (b
) != stmt
573 && same_data_refs_base_objects (a
, b
))
575 tree cb
= bb_predicate (gimple_bb (DR_STMT (b
)));
577 if (DR_WRITTEN_AT_LEAST_ONCE (b
) == 1
578 || is_true_predicate (cb
)
579 || is_true_predicate (ca
= fold_or_predicates (EXPR_LOCATION (cb
),
582 DR_WRITTEN_AT_LEAST_ONCE (a
) = 1;
583 DR_WRITTEN_AT_LEAST_ONCE (b
) = 1;
591 DR_WRITTEN_AT_LEAST_ONCE (a
) = 0;
599 /* Return true when the memory references of STMT won't trap in the
600 if-converted code. There are two things that we have to check for:
602 - writes to memory occur to writable memory: if-conversion of
603 memory writes transforms the conditional memory writes into
604 unconditional writes, i.e. "if (cond) A[i] = foo" is transformed
605 into "A[i] = cond ? foo : A[i]", and as the write to memory may not
606 be executed at all in the original code, it may be a readonly
607 memory. To check that A is not const-qualified, we check that
608 there exists at least an unconditional write to A in the current
611 - reads or writes to memory are valid memory accesses for every
612 iteration. To check that the memory accesses are correctly formed
613 and that we are allowed to read and write in these locations, we
614 check that the memory accesses to be if-converted occur at every
615 iteration unconditionally. */
618 ifcvt_memrefs_wont_trap (gimple stmt
, VEC (data_reference_p
, heap
) *refs
)
620 return write_memrefs_written_at_least_once (stmt
, refs
)
621 && memrefs_read_or_written_unconditionally (stmt
, refs
);
624 /* Wrapper around gimple_could_trap_p refined for the needs of the
625 if-conversion. Try to prove that the memory accesses of STMT could
626 not trap in the innermost loop containing STMT. */
629 ifcvt_could_trap_p (gimple stmt
, VEC (data_reference_p
, heap
) *refs
)
631 if (gimple_vuse (stmt
)
632 && !gimple_could_trap_p_1 (stmt
, false, false)
633 && ifcvt_memrefs_wont_trap (stmt
, refs
))
636 return gimple_could_trap_p (stmt
);
639 /* Return true when STMT is if-convertible.
641 GIMPLE_ASSIGN statement is not if-convertible if,
644 - LHS is not var decl. */
647 if_convertible_gimple_assign_stmt_p (gimple stmt
,
648 VEC (data_reference_p
, heap
) *refs
)
650 tree lhs
= gimple_assign_lhs (stmt
);
653 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
655 fprintf (dump_file
, "-------------------------\n");
656 print_gimple_stmt (dump_file
, stmt
, 0, TDF_SLIM
);
659 if (!is_gimple_reg_type (TREE_TYPE (lhs
)))
662 /* Some of these constrains might be too conservative. */
663 if (stmt_ends_bb_p (stmt
)
664 || gimple_has_volatile_ops (stmt
)
665 || (TREE_CODE (lhs
) == SSA_NAME
666 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs
))
667 || gimple_has_side_effects (stmt
))
669 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
670 fprintf (dump_file
, "stmt not suitable for ifcvt\n");
674 if (flag_tree_loop_if_convert_stores
)
676 if (ifcvt_could_trap_p (stmt
, refs
))
678 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
679 fprintf (dump_file
, "tree could trap...\n");
685 if (gimple_assign_rhs_could_trap_p (stmt
))
687 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
688 fprintf (dump_file
, "tree could trap...\n");
692 bb
= gimple_bb (stmt
);
694 if (TREE_CODE (lhs
) != SSA_NAME
695 && bb
!= bb
->loop_father
->header
696 && !bb_with_exit_edge_p (bb
->loop_father
, bb
))
698 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
700 fprintf (dump_file
, "LHS is not var\n");
701 print_gimple_stmt (dump_file
, stmt
, 0, TDF_SLIM
);
709 /* Return true when STMT is if-convertible.
711 A statement is if-convertible if:
712 - it is an if-convertible GIMPLE_ASSIGN,
713 - it is a GIMPLE_LABEL or a GIMPLE_COND. */
716 if_convertible_stmt_p (gimple stmt
, VEC (data_reference_p
, heap
) *refs
)
718 switch (gimple_code (stmt
))
726 return if_convertible_gimple_assign_stmt_p (stmt
, refs
);
730 tree fndecl
= gimple_call_fndecl (stmt
);
733 int flags
= gimple_call_flags (stmt
);
734 if ((flags
& ECF_CONST
)
735 && !(flags
& ECF_LOOPING_CONST_OR_PURE
)
736 /* We can only vectorize some builtins at the moment,
737 so restrict if-conversion to those. */
738 && DECL_BUILT_IN (fndecl
))
745 /* Don't know what to do with 'em so don't do anything. */
746 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
748 fprintf (dump_file
, "don't know what to do\n");
749 print_gimple_stmt (dump_file
, stmt
, 0, TDF_SLIM
);
758 /* Return true when BB post-dominates all its predecessors. */
761 bb_postdominates_preds (basic_block bb
)
765 for (i
= 0; i
< EDGE_COUNT (bb
->preds
); i
++)
766 if (!dominated_by_p (CDI_POST_DOMINATORS
, EDGE_PRED (bb
, i
)->src
, bb
))
772 /* Return true when BB is if-convertible. This routine does not check
773 basic block's statements and phis.
775 A basic block is not if-convertible if:
776 - it is non-empty and it is after the exit block (in BFS order),
777 - it is after the exit block but before the latch,
778 - its edges are not normal.
780 EXIT_BB is the basic block containing the exit of the LOOP. BB is
784 if_convertible_bb_p (struct loop
*loop
, basic_block bb
, basic_block exit_bb
)
789 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
790 fprintf (dump_file
, "----------[%d]-------------\n", bb
->index
);
792 if (EDGE_COUNT (bb
->preds
) > 2
793 || EDGE_COUNT (bb
->succs
) > 2)
798 if (bb
!= loop
->latch
)
800 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
801 fprintf (dump_file
, "basic block after exit bb but before latch\n");
804 else if (!empty_block_p (bb
))
806 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
807 fprintf (dump_file
, "non empty basic block after exit bb\n");
810 else if (bb
== loop
->latch
812 && !dominated_by_p (CDI_DOMINATORS
, bb
, exit_bb
))
814 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
815 fprintf (dump_file
, "latch is not dominated by exit_block\n");
820 /* Be less adventurous and handle only normal edges. */
821 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
822 if (e
->flags
& (EDGE_EH
| EDGE_ABNORMAL
| EDGE_IRREDUCIBLE_LOOP
))
824 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
825 fprintf (dump_file
, "Difficult to handle edges\n");
829 if (EDGE_COUNT (bb
->preds
) == 2
830 && bb
!= loop
->header
831 && !bb_postdominates_preds (bb
))
837 /* Return true when all predecessor blocks of BB are visited. The
838 VISITED bitmap keeps track of the visited blocks. */
841 pred_blocks_visited_p (basic_block bb
, bitmap
*visited
)
845 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
846 if (!bitmap_bit_p (*visited
, e
->src
->index
))
852 /* Get body of a LOOP in suitable order for if-conversion. It is
853 caller's responsibility to deallocate basic block list.
854 If-conversion suitable order is, breadth first sort (BFS) order
855 with an additional constraint: select a block only if all its
856 predecessors are already selected. */
859 get_loop_body_in_if_conv_order (const struct loop
*loop
)
861 basic_block
*blocks
, *blocks_in_bfs_order
;
864 unsigned int index
= 0;
865 unsigned int visited_count
= 0;
867 gcc_assert (loop
->num_nodes
);
868 gcc_assert (loop
->latch
!= EXIT_BLOCK_PTR
);
870 blocks
= XCNEWVEC (basic_block
, loop
->num_nodes
);
871 visited
= BITMAP_ALLOC (NULL
);
873 blocks_in_bfs_order
= get_loop_body_in_bfs_order (loop
);
876 while (index
< loop
->num_nodes
)
878 bb
= blocks_in_bfs_order
[index
];
880 if (bb
->flags
& BB_IRREDUCIBLE_LOOP
)
882 free (blocks_in_bfs_order
);
883 BITMAP_FREE (visited
);
888 if (!bitmap_bit_p (visited
, bb
->index
))
890 if (pred_blocks_visited_p (bb
, &visited
)
891 || bb
== loop
->header
)
893 /* This block is now visited. */
894 bitmap_set_bit (visited
, bb
->index
);
895 blocks
[visited_count
++] = bb
;
901 if (index
== loop
->num_nodes
902 && visited_count
!= loop
->num_nodes
)
906 free (blocks_in_bfs_order
);
907 BITMAP_FREE (visited
);
911 /* Returns true when the analysis of the predicates for all the basic
912 blocks in LOOP succeeded.
914 predicate_bbs first allocates the predicates of the basic blocks.
915 These fields are then initialized with the tree expressions
916 representing the predicates under which a basic block is executed
917 in the LOOP. As the loop->header is executed at each iteration, it
918 has the "true" predicate. Other statements executed under a
919 condition are predicated with that condition, for example
926 S1 will be predicated with "x", and
927 S2 will be predicated with "!x". */
930 predicate_bbs (loop_p loop
)
934 for (i
= 0; i
< loop
->num_nodes
; i
++)
935 init_bb_predicate (ifc_bbs
[i
]);
937 for (i
= 0; i
< loop
->num_nodes
; i
++)
939 basic_block bb
= ifc_bbs
[i
];
941 gimple_stmt_iterator itr
;
943 /* The loop latch is always executed and has no extra conditions
944 to be processed: skip it. */
945 if (bb
== loop
->latch
)
947 reset_bb_predicate (loop
->latch
);
951 cond
= bb_predicate (bb
);
953 for (itr
= gsi_start_bb (bb
); !gsi_end_p (itr
); gsi_next (&itr
))
955 gimple stmt
= gsi_stmt (itr
);
957 switch (gimple_code (stmt
))
968 edge true_edge
, false_edge
;
969 location_t loc
= gimple_location (stmt
);
970 tree c
= fold_build2_loc (loc
, gimple_cond_code (stmt
),
972 gimple_cond_lhs (stmt
),
973 gimple_cond_rhs (stmt
));
975 /* Add new condition into destination's predicate list. */
976 extract_true_false_edges_from_block (gimple_bb (stmt
),
977 &true_edge
, &false_edge
);
979 /* If C is true, then TRUE_EDGE is taken. */
980 add_to_dst_predicate_list (loop
, true_edge
,
984 /* If C is false, then FALSE_EDGE is taken. */
985 c2
= build1_loc (loc
, TRUTH_NOT_EXPR
,
986 boolean_type_node
, unshare_expr (c
));
987 add_to_dst_predicate_list (loop
, false_edge
,
988 unshare_expr (cond
), c2
);
995 /* Not handled yet in if-conversion. */
1000 /* If current bb has only one successor, then consider it as an
1001 unconditional goto. */
1002 if (single_succ_p (bb
))
1004 basic_block bb_n
= single_succ (bb
);
1006 /* The successor bb inherits the predicate of its
1007 predecessor. If there is no predicate in the predecessor
1008 bb, then consider the successor bb as always executed. */
1009 if (cond
== NULL_TREE
)
1010 cond
= boolean_true_node
;
1012 add_to_predicate_list (bb_n
, cond
);
1016 /* The loop header is always executed. */
1017 reset_bb_predicate (loop
->header
);
1018 gcc_assert (bb_predicate_gimplified_stmts (loop
->header
) == NULL
1019 && bb_predicate_gimplified_stmts (loop
->latch
) == NULL
);
1024 /* Return true when LOOP is if-convertible. This is a helper function
1025 for if_convertible_loop_p. REFS and DDRS are initialized and freed
1026 in if_convertible_loop_p. */
1029 if_convertible_loop_p_1 (struct loop
*loop
,
1030 VEC (loop_p
, heap
) **loop_nest
,
1031 VEC (data_reference_p
, heap
) **refs
,
1032 VEC (ddr_p
, heap
) **ddrs
)
1036 basic_block exit_bb
= NULL
;
1038 /* Don't if-convert the loop when the data dependences cannot be
1039 computed: the loop won't be vectorized in that case. */
1040 res
= compute_data_dependences_for_loop (loop
, true, loop_nest
, refs
, ddrs
);
1044 calculate_dominance_info (CDI_DOMINATORS
);
1045 calculate_dominance_info (CDI_POST_DOMINATORS
);
1047 /* Allow statements that can be handled during if-conversion. */
1048 ifc_bbs
= get_loop_body_in_if_conv_order (loop
);
1051 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1052 fprintf (dump_file
, "Irreducible loop\n");
1056 for (i
= 0; i
< loop
->num_nodes
; i
++)
1058 basic_block bb
= ifc_bbs
[i
];
1060 if (!if_convertible_bb_p (loop
, bb
, exit_bb
))
1063 if (bb_with_exit_edge_p (loop
, bb
))
1067 res
= predicate_bbs (loop
);
1071 if (flag_tree_loop_if_convert_stores
)
1073 data_reference_p dr
;
1075 for (i
= 0; VEC_iterate (data_reference_p
, *refs
, i
, dr
); i
++)
1077 dr
->aux
= XNEW (struct ifc_dr
);
1078 DR_WRITTEN_AT_LEAST_ONCE (dr
) = -1;
1079 DR_RW_UNCONDITIONALLY (dr
) = -1;
1083 for (i
= 0; i
< loop
->num_nodes
; i
++)
1085 basic_block bb
= ifc_bbs
[i
];
1086 gimple_stmt_iterator itr
;
1088 for (itr
= gsi_start_phis (bb
); !gsi_end_p (itr
); gsi_next (&itr
))
1089 if (!if_convertible_phi_p (loop
, bb
, gsi_stmt (itr
)))
1092 /* Check the if-convertibility of statements in predicated BBs. */
1093 if (is_predicated (bb
))
1094 for (itr
= gsi_start_bb (bb
); !gsi_end_p (itr
); gsi_next (&itr
))
1095 if (!if_convertible_stmt_p (gsi_stmt (itr
), *refs
))
1100 fprintf (dump_file
, "Applying if-conversion\n");
1105 /* Return true when LOOP is if-convertible.
1106 LOOP is if-convertible if:
1108 - it has two or more basic blocks,
1109 - it has only one exit,
1110 - loop header is not the exit edge,
1111 - if its basic blocks and phi nodes are if convertible. */
1114 if_convertible_loop_p (struct loop
*loop
)
1119 VEC (data_reference_p
, heap
) *refs
;
1120 VEC (ddr_p
, heap
) *ddrs
;
1121 VEC (loop_p
, heap
) *loop_nest
;
1123 /* Handle only innermost loop. */
1124 if (!loop
|| loop
->inner
)
1126 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1127 fprintf (dump_file
, "not innermost loop\n");
1131 /* If only one block, no need for if-conversion. */
1132 if (loop
->num_nodes
<= 2)
1134 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1135 fprintf (dump_file
, "less than 2 basic blocks\n");
1139 /* More than one loop exit is too much to handle. */
1140 if (!single_exit (loop
))
1142 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1143 fprintf (dump_file
, "multiple exits\n");
1147 /* If one of the loop header's edge is an exit edge then do not
1148 apply if-conversion. */
1149 FOR_EACH_EDGE (e
, ei
, loop
->header
->succs
)
1150 if (loop_exit_edge_p (loop
, e
))
1153 refs
= VEC_alloc (data_reference_p
, heap
, 5);
1154 ddrs
= VEC_alloc (ddr_p
, heap
, 25);
1155 loop_nest
= VEC_alloc (loop_p
, heap
, 3);
1156 res
= if_convertible_loop_p_1 (loop
, &loop_nest
, &refs
, &ddrs
);
1158 if (flag_tree_loop_if_convert_stores
)
1160 data_reference_p dr
;
1163 for (i
= 0; VEC_iterate (data_reference_p
, refs
, i
, dr
); i
++)
1167 VEC_free (loop_p
, heap
, loop_nest
);
1168 free_data_refs (refs
);
1169 free_dependence_relations (ddrs
);
1173 /* Basic block BB has two predecessors. Using predecessor's bb
1174 predicate, set an appropriate condition COND for the PHI node
1175 replacement. Return the true block whose phi arguments are
1176 selected when cond is true. LOOP is the loop containing the
1177 if-converted region, GSI is the place to insert the code for the
1181 find_phi_replacement_condition (struct loop
*loop
,
1182 basic_block bb
, tree
*cond
,
1183 gimple_stmt_iterator
*gsi
)
1185 edge first_edge
, second_edge
;
1188 gcc_assert (EDGE_COUNT (bb
->preds
) == 2);
1189 first_edge
= EDGE_PRED (bb
, 0);
1190 second_edge
= EDGE_PRED (bb
, 1);
1192 /* Use condition based on following criteria:
1198 S2 is preferred over S1. Make 'b' first_bb and use its condition.
1200 2) Do not make loop header first_bb.
1203 S1: x = !(c == d)? a : b;
1206 S22: x = t1 ? b : a;
1208 S3: x = (c == d) ? b : a;
1210 S3 is preferred over S1 and S2*, Make 'b' first_bb and use
1213 4) If pred B is dominated by pred A then use pred B's condition.
1216 /* Select condition that is not TRUTH_NOT_EXPR. */
1217 tmp_cond
= bb_predicate (first_edge
->src
);
1218 gcc_assert (tmp_cond
);
1220 if (TREE_CODE (tmp_cond
) == TRUTH_NOT_EXPR
)
1224 tmp_edge
= first_edge
;
1225 first_edge
= second_edge
;
1226 second_edge
= tmp_edge
;
1229 /* Check if FIRST_BB is loop header or not and make sure that
1230 FIRST_BB does not dominate SECOND_BB. */
1231 if (first_edge
->src
== loop
->header
1232 || dominated_by_p (CDI_DOMINATORS
,
1233 second_edge
->src
, first_edge
->src
))
1235 *cond
= bb_predicate (second_edge
->src
);
1237 if (TREE_CODE (*cond
) == TRUTH_NOT_EXPR
)
1238 *cond
= TREE_OPERAND (*cond
, 0);
1240 /* Select non loop header bb. */
1241 first_edge
= second_edge
;
1244 *cond
= bb_predicate (first_edge
->src
);
1246 /* Gimplify the condition to a valid cond-expr conditonal operand. */
1247 *cond
= force_gimple_operand_gsi_1 (gsi
, unshare_expr (*cond
),
1248 is_gimple_condexpr
, NULL_TREE
,
1249 true, GSI_SAME_STMT
);
1251 return first_edge
->src
;
1254 /* Replace a scalar PHI node with a COND_EXPR using COND as condition.
1255 This routine does not handle PHI nodes with more than two
1259 S1: A = PHI <x1(1), x2(5)>
1261 S2: A = cond ? x1 : x2;
1263 The generated code is inserted at GSI that points to the top of
1264 basic block's statement list. When COND is true, phi arg from
1265 TRUE_BB is selected. */
1268 predicate_scalar_phi (gimple phi
, tree cond
,
1269 basic_block true_bb
,
1270 gimple_stmt_iterator
*gsi
)
1274 tree rhs
, res
, arg
, scev
;
1276 gcc_assert (gimple_code (phi
) == GIMPLE_PHI
1277 && gimple_phi_num_args (phi
) == 2);
1279 res
= gimple_phi_result (phi
);
1280 /* Do not handle virtual phi nodes. */
1281 if (!is_gimple_reg (SSA_NAME_VAR (res
)))
1284 bb
= gimple_bb (phi
);
1286 if ((arg
= degenerate_phi_result (phi
))
1287 || ((scev
= analyze_scalar_evolution (gimple_bb (phi
)->loop_father
,
1289 && !chrec_contains_undetermined (scev
)
1291 && (arg
= gimple_phi_arg_def (phi
, 0))))
1296 /* Use condition that is not TRUTH_NOT_EXPR in conditional modify expr. */
1297 if (EDGE_PRED (bb
, 1)->src
== true_bb
)
1299 arg_0
= gimple_phi_arg_def (phi
, 1);
1300 arg_1
= gimple_phi_arg_def (phi
, 0);
1304 arg_0
= gimple_phi_arg_def (phi
, 0);
1305 arg_1
= gimple_phi_arg_def (phi
, 1);
1308 gcc_checking_assert (bb
== bb
->loop_father
->header
1309 || bb_postdominates_preds (bb
));
1311 /* Build new RHS using selected condition and arguments. */
1312 rhs
= build3 (COND_EXPR
, TREE_TYPE (res
),
1313 unshare_expr (cond
), arg_0
, arg_1
);
1316 new_stmt
= gimple_build_assign (res
, rhs
);
1317 SSA_NAME_DEF_STMT (gimple_phi_result (phi
)) = new_stmt
;
1318 gsi_insert_before (gsi
, new_stmt
, GSI_SAME_STMT
);
1319 update_stmt (new_stmt
);
1321 if (dump_file
&& (dump_flags
& TDF_DETAILS
))
1323 fprintf (dump_file
, "new phi replacement stmt\n");
1324 print_gimple_stmt (dump_file
, new_stmt
, 0, TDF_SLIM
);
1328 /* Replaces in LOOP all the scalar phi nodes other than those in the
1329 LOOP->header block with conditional modify expressions. */
1332 predicate_all_scalar_phis (struct loop
*loop
)
1335 unsigned int orig_loop_num_nodes
= loop
->num_nodes
;
1338 for (i
= 1; i
< orig_loop_num_nodes
; i
++)
1341 tree cond
= NULL_TREE
;
1342 gimple_stmt_iterator gsi
, phi_gsi
;
1343 basic_block true_bb
= NULL
;
1346 if (bb
== loop
->header
)
1349 phi_gsi
= gsi_start_phis (bb
);
1350 if (gsi_end_p (phi_gsi
))
1353 /* BB has two predecessors. Using predecessor's aux field, set
1354 appropriate condition for the PHI node replacement. */
1355 gsi
= gsi_after_labels (bb
);
1356 true_bb
= find_phi_replacement_condition (loop
, bb
, &cond
, &gsi
);
1358 while (!gsi_end_p (phi_gsi
))
1360 phi
= gsi_stmt (phi_gsi
);
1361 predicate_scalar_phi (phi
, cond
, true_bb
, &gsi
);
1362 release_phi_node (phi
);
1363 gsi_next (&phi_gsi
);
1366 set_phi_nodes (bb
, NULL
);
1370 /* Insert in each basic block of LOOP the statements produced by the
1371 gimplification of the predicates. */
1374 insert_gimplified_predicates (loop_p loop
)
1378 for (i
= 0; i
< loop
->num_nodes
; i
++)
1380 basic_block bb
= ifc_bbs
[i
];
1383 if (!is_predicated (bb
))
1385 /* Do not insert statements for a basic block that is not
1386 predicated. Also make sure that the predicate of the
1387 basic block is set to true. */
1388 reset_bb_predicate (bb
);
1392 stmts
= bb_predicate_gimplified_stmts (bb
);
1395 if (flag_tree_loop_if_convert_stores
)
1397 /* Insert the predicate of the BB just after the label,
1398 as the if-conversion of memory writes will use this
1400 gimple_stmt_iterator gsi
= gsi_after_labels (bb
);
1401 gsi_insert_seq_before (&gsi
, stmts
, GSI_SAME_STMT
);
1405 /* Insert the predicate of the BB at the end of the BB
1406 as this would reduce the register pressure: the only
1407 use of this predicate will be in successor BBs. */
1408 gimple_stmt_iterator gsi
= gsi_last_bb (bb
);
1411 || stmt_ends_bb_p (gsi_stmt (gsi
)))
1412 gsi_insert_seq_before (&gsi
, stmts
, GSI_SAME_STMT
);
1414 gsi_insert_seq_after (&gsi
, stmts
, GSI_SAME_STMT
);
1417 /* Once the sequence is code generated, set it to NULL. */
1418 set_bb_predicate_gimplified_stmts (bb
, NULL
);
1423 /* Predicate each write to memory in LOOP.
1425 This function transforms control flow constructs containing memory
1428 | for (i = 0; i < N; i++)
1432 into the following form that does not contain control flow:
1434 | for (i = 0; i < N; i++)
1435 | A[i] = cond ? expr : A[i];
1437 The original CFG looks like this:
1444 | if (i < N) goto bb_5 else goto bb_2
1448 | cond = some_computation;
1449 | if (cond) goto bb_3 else goto bb_4
1461 insert_gimplified_predicates inserts the computation of the COND
1462 expression at the beginning of the destination basic block:
1469 | if (i < N) goto bb_5 else goto bb_2
1473 | cond = some_computation;
1474 | if (cond) goto bb_3 else goto bb_4
1478 | cond = some_computation;
1487 predicate_mem_writes is then predicating the memory write as follows:
1494 | if (i < N) goto bb_5 else goto bb_2
1498 | if (cond) goto bb_3 else goto bb_4
1502 | cond = some_computation;
1503 | A[i] = cond ? expr : A[i];
1511 and finally combine_blocks removes the basic block boundaries making
1512 the loop vectorizable:
1516 | if (i < N) goto bb_5 else goto bb_1
1520 | cond = some_computation;
1521 | A[i] = cond ? expr : A[i];
1522 | if (i < N) goto bb_5 else goto bb_4
1531 predicate_mem_writes (loop_p loop
)
1533 unsigned int i
, orig_loop_num_nodes
= loop
->num_nodes
;
1535 for (i
= 1; i
< orig_loop_num_nodes
; i
++)
1537 gimple_stmt_iterator gsi
;
1538 basic_block bb
= ifc_bbs
[i
];
1539 tree cond
= bb_predicate (bb
);
1543 if (is_true_predicate (cond
))
1547 if (TREE_CODE (cond
) == TRUTH_NOT_EXPR
)
1550 cond
= TREE_OPERAND (cond
, 0);
1553 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1554 if ((stmt
= gsi_stmt (gsi
))
1555 && gimple_assign_single_p (stmt
)
1556 && gimple_vdef (stmt
))
1558 tree lhs
= gimple_assign_lhs (stmt
);
1559 tree rhs
= gimple_assign_rhs1 (stmt
);
1560 tree type
= TREE_TYPE (lhs
);
1562 lhs
= ifc_temp_var (type
, unshare_expr (lhs
), &gsi
);
1563 rhs
= ifc_temp_var (type
, unshare_expr (rhs
), &gsi
);
1570 cond
= force_gimple_operand_gsi_1 (&gsi
, unshare_expr (cond
),
1571 is_gimple_condexpr
, NULL_TREE
,
1572 true, GSI_SAME_STMT
);
1573 rhs
= build3 (COND_EXPR
, type
, unshare_expr (cond
), rhs
, lhs
);
1574 gimple_assign_set_rhs1 (stmt
, ifc_temp_var (type
, rhs
, &gsi
));
1580 /* Remove all GIMPLE_CONDs and GIMPLE_LABELs of all the basic blocks
1581 other than the exit and latch of the LOOP. Also resets the
1582 GIMPLE_DEBUG information. */
1585 remove_conditions_and_labels (loop_p loop
)
1587 gimple_stmt_iterator gsi
;
1590 for (i
= 0; i
< loop
->num_nodes
; i
++)
1592 basic_block bb
= ifc_bbs
[i
];
1594 if (bb_with_exit_edge_p (loop
, bb
)
1595 || bb
== loop
->latch
)
1598 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); )
1599 switch (gimple_code (gsi_stmt (gsi
)))
1603 gsi_remove (&gsi
, true);
1607 /* ??? Should there be conditional GIMPLE_DEBUG_BINDs? */
1608 if (gimple_debug_bind_p (gsi_stmt (gsi
)))
1610 gimple_debug_bind_reset_value (gsi_stmt (gsi
));
1611 update_stmt (gsi_stmt (gsi
));
1622 /* Combine all the basic blocks from LOOP into one or two super basic
1623 blocks. Replace PHI nodes with conditional modify expressions. */
1626 combine_blocks (struct loop
*loop
)
1628 basic_block bb
, exit_bb
, merge_target_bb
;
1629 unsigned int orig_loop_num_nodes
= loop
->num_nodes
;
1634 remove_conditions_and_labels (loop
);
1635 insert_gimplified_predicates (loop
);
1636 predicate_all_scalar_phis (loop
);
1638 if (flag_tree_loop_if_convert_stores
)
1639 predicate_mem_writes (loop
);
1641 /* Merge basic blocks: first remove all the edges in the loop,
1642 except for those from the exit block. */
1644 for (i
= 0; i
< orig_loop_num_nodes
; i
++)
1647 free_bb_predicate (bb
);
1648 if (bb_with_exit_edge_p (loop
, bb
))
1650 gcc_assert (exit_bb
== NULL
);
1654 gcc_assert (exit_bb
!= loop
->latch
);
1656 for (i
= 1; i
< orig_loop_num_nodes
; i
++)
1660 for (ei
= ei_start (bb
->preds
); (e
= ei_safe_edge (ei
));)
1662 if (e
->src
== exit_bb
)
1669 if (exit_bb
!= NULL
)
1671 if (exit_bb
!= loop
->header
)
1673 /* Connect this node to loop header. */
1674 make_edge (loop
->header
, exit_bb
, EDGE_FALLTHRU
);
1675 set_immediate_dominator (CDI_DOMINATORS
, exit_bb
, loop
->header
);
1678 /* Redirect non-exit edges to loop->latch. */
1679 FOR_EACH_EDGE (e
, ei
, exit_bb
->succs
)
1681 if (!loop_exit_edge_p (loop
, e
))
1682 redirect_edge_and_branch (e
, loop
->latch
);
1684 set_immediate_dominator (CDI_DOMINATORS
, loop
->latch
, exit_bb
);
1688 /* If the loop does not have an exit, reconnect header and latch. */
1689 make_edge (loop
->header
, loop
->latch
, EDGE_FALLTHRU
);
1690 set_immediate_dominator (CDI_DOMINATORS
, loop
->latch
, loop
->header
);
1693 merge_target_bb
= loop
->header
;
1694 for (i
= 1; i
< orig_loop_num_nodes
; i
++)
1696 gimple_stmt_iterator gsi
;
1697 gimple_stmt_iterator last
;
1701 if (bb
== exit_bb
|| bb
== loop
->latch
)
1704 /* Make stmts member of loop->header. */
1705 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1706 gimple_set_bb (gsi_stmt (gsi
), merge_target_bb
);
1708 /* Update stmt list. */
1709 last
= gsi_last_bb (merge_target_bb
);
1710 gsi_insert_seq_after (&last
, bb_seq (bb
), GSI_NEW_STMT
);
1711 set_bb_seq (bb
, NULL
);
1713 delete_basic_block (bb
);
1716 /* If possible, merge loop header to the block with the exit edge.
1717 This reduces the number of basic blocks to two, to please the
1718 vectorizer that handles only loops with two nodes. */
1720 && exit_bb
!= loop
->header
1721 && can_merge_blocks_p (loop
->header
, exit_bb
))
1722 merge_blocks (loop
->header
, exit_bb
);
1727 /* Post-dominators are corrupt now. */
1728 free_dominance_info (CDI_POST_DOMINATORS
);
1731 /* If-convert LOOP when it is legal. For the moment this pass has no
1732 profitability analysis. Returns true when something changed. */
1735 tree_if_conversion (struct loop
*loop
)
1737 bool changed
= false;
1740 if (!if_convertible_loop_p (loop
)
1741 || !dbg_cnt (if_conversion_tree
))
1744 /* Now all statements are if-convertible. Combine all the basic
1745 blocks into one huge basic block doing the if-conversion
1747 combine_blocks (loop
);
1749 if (flag_tree_loop_if_convert_stores
)
1750 mark_sym_for_renaming (gimple_vop (cfun
));
1759 for (i
= 0; i
< loop
->num_nodes
; i
++)
1760 free_bb_predicate (ifc_bbs
[i
]);
1769 /* Tree if-conversion pass management. */
1772 main_tree_if_conversion (void)
1776 bool changed
= false;
1779 if (number_of_loops () <= 1)
1782 FOR_EACH_LOOP (li
, loop
, 0)
1783 changed
|= tree_if_conversion (loop
);
1786 todo
|= TODO_cleanup_cfg
;
1788 if (changed
&& flag_tree_loop_if_convert_stores
)
1789 todo
|= TODO_update_ssa_only_virtuals
;
1791 free_dominance_info (CDI_POST_DOMINATORS
);
1793 #ifdef ENABLE_CHECKING
1797 gcc_assert (!bb
->aux
);
1804 /* Returns true when the if-conversion pass is enabled. */
1807 gate_tree_if_conversion (void)
1809 return ((flag_tree_vectorize
&& flag_tree_loop_if_convert
!= 0)
1810 || flag_tree_loop_if_convert
== 1
1811 || flag_tree_loop_if_convert_stores
== 1);
1814 struct gimple_opt_pass pass_if_conversion
=
1819 gate_tree_if_conversion
, /* gate */
1820 main_tree_if_conversion
, /* execute */
1823 0, /* static_pass_number */
1824 TV_NONE
, /* tv_id */
1825 PROP_cfg
| PROP_ssa
, /* properties_required */
1826 0, /* properties_provided */
1827 0, /* properties_destroyed */
1828 0, /* todo_flags_start */
1829 TODO_verify_stmts
| TODO_verify_flow
1830 /* todo_flags_finish */