GCC Middle and Back End API Reference
|
Data Structures | |
struct | bb_predicate_s |
struct | ifc_dr |
Typedefs | |
typedef struct bb_predicate_s * | bb_predicate_p |
Variables | |
static basic_block * | ifc_bbs |
typedef struct bb_predicate_s * bb_predicate_p |
Structure used to predicate basic blocks. This is attached to the ->aux field of the BBs in the loop to be if-converted.
|
inlinestatic |
Adds the sequence of statements STMTS to the sequence of statements of the predicate for basic block BB.
References basic_block_def::aux, and gimple_seq_add_seq().
Referenced by add_to_predicate_list().
|
static |
Add the condition COND to the previous condition PREV_COND, and add this to the predicate list of the destination of edge E. LOOP is the loop to be if-converted.
References add_to_predicate_list(), edge_def::dest, flow_bb_inside_loop_p(), and is_true_predicate().
Referenced by predicate_bbs().
|
inlinestatic |
Add condition NC to the predicate list of basic block BB.
References add_bb_predicate_gimplified_stmts(), bb_predicate(), fold_or_predicates(), force_gimple_operand_1(), is_gimple_condexpr(), is_predicated(), is_true_predicate(), reset_bb_predicate(), and set_bb_predicate().
Referenced by add_to_dst_predicate_list(), and predicate_bbs().
|
inlinestatic |
Returns true when the basic block BB has a predicate.
References basic_block_def::aux.
Referenced by free_bb_predicate().
|
inlinestatic |
Returns the gimplified predicate for basic block BB.
References basic_block_def::aux.
Referenced by add_to_predicate_list(), find_phi_replacement_condition(), is_predicated(), memrefs_read_or_written_unconditionally(), predicate_bbs(), predicate_mem_writes(), and write_memrefs_written_at_least_once().
|
inlinestatic |
Returns the sequence of statements of the gimplification of the predicate for basic block BB.
References basic_block_def::aux.
Referenced by free_bb_predicate(), insert_gimplified_predicates(), and predicate_bbs().
|
static |
Return true if one of the successor edges of BB exits LOOP.
References loop_exit_edge_p(), and basic_block_def::succs.
Referenced by combine_blocks(), if_convertible_gimple_assign_stmt_p(), if_convertible_loop_p_1(), and remove_conditions_and_labels().
|
static |
Combine all the basic blocks from LOOP into one or two super basic blocks. Replace PHI nodes with conditional modify expressions.
References bb_seq(), bb_with_exit_edge_p(), can_merge_blocks_p(), CDI_DOMINATORS, delete_basic_block(), ei_next(), ei_safe_edge(), free(), free_bb_predicate(), gimple_set_bb(), gsi_end_p(), gsi_insert_seq_after(), gsi_last_bb(), GSI_NEW_STMT, gsi_next(), gsi_start_bb(), gsi_stmt(), loop::header, insert_gimplified_predicates(), last, loop::latch, loop_exit_edge_p(), make_edge(), merge_blocks(), loop::num_nodes, predicate_all_scalar_phis(), predicate_mem_writes(), basic_block_def::preds, redirect_edge_and_branch(), remove_conditions_and_labels(), remove_edge(), set_bb_seq(), set_immediate_dominator(), edge_def::src, and basic_block_def::succs.
Referenced by tree_if_conversion().
|
static |
Returns true if N is either a constant or a SSA_NAME.
Referenced by fold_build_cond_expr().
|
static |
Basic block BB has two predecessors. Using predecessor's bb predicate, set an appropriate condition COND for the PHI node replacement. Return the true block whose phi arguments are selected when cond is true. LOOP is the loop containing the if-converted region, GSI is the place to insert the code for the if-conversion.
References bb_predicate(), force_gimple_operand_gsi_1(), GSI_SAME_STMT, is_gimple_condexpr(), basic_block_def::preds, edge_def::src, basic_block_def::succs, and unshare_expr().
Referenced by predicate_all_scalar_phis().
|
static |
Returns either a COND_EXPR or the folded expression if the folded expression is a MIN_EXPR, a MAX_EXPR, an ABS_EXPR, a constant or a SSA_NAME.
References constant_or_ssa_name().
Referenced by predicate_mem_writes(), and predicate_scalar_phi().
|
static |
Returns the fold of predicate C1 OR C2 at location LOC.
References maybe_fold_or_comparisons(), and parse_predicate().
Referenced by add_to_predicate_list(), memrefs_read_or_written_unconditionally(), and write_memrefs_written_at_least_once().
|
inlinestatic |
Free the predicate of basic block BB.
References basic_block_def::aux, bb_has_predicate(), bb_predicate_gimplified_stmts(), free(), free_stmt_operands(), gsi_end_p(), gsi_next(), and gsi_stmt().
Referenced by combine_blocks(), reset_bb_predicate(), and tree_if_conversion().
|
static |
Returns true when the if-conversion pass is enabled.
References cfun, and function::has_force_vect_loops.
|
static |
Get body of a LOOP in suitable order for if-conversion. It is caller's responsibility to deallocate basic block list. If-conversion suitable order is, breadth first sort (BFS) order with an additional constraint: select a block only if all its predecessors are already selected.
References bitmap_bit_p(), bitmap_set_bit(), basic_block_def::flags, free(), get_loop_body_in_bfs_order(), loop::header, basic_block_def::index, loop::latch, loop::num_nodes, pred_blocks_visited_p(), and visited.
Referenced by if_convertible_loop_p_1().
|
static |
Return true when BB is if-convertible. This routine does not check basic block's statements and phis. A basic block is not if-convertible if: - it is non-empty and it is after the exit block (in BFS order), - it is after the exit block but before the latch, - its edges are not normal. EXIT_BB is the basic block containing the exit of the LOOP. BB is inside LOOP.
References CDI_DOMINATORS, dominated_by_p(), dump_file, dump_flags, empty_block_p(), edge_def::flags, loop::header, basic_block_def::index, loop::latch, basic_block_def::preds, edge_def::src, and basic_block_def::succs.
Referenced by if_convertible_loop_p_1().
|
static |
Return true when STMT is if-convertible. GIMPLE_ASSIGN statement is not if-convertible if, - it is not movable, - it could trap, - LHS is not var decl.
References bb_with_exit_edge_p(), dump_file, dump_flags, gimple_assign_lhs(), gimple_assign_rhs_could_trap_p(), gimple_bb(), gimple_has_side_effects(), gimple_has_volatile_ops(), loop::header, ifcvt_could_trap_p(), is_gimple_reg_type(), basic_block_def::loop_father, print_gimple_stmt(), and stmt_ends_bb_p().
Referenced by if_convertible_stmt_p().
|
static |
Return true when LOOP is if-convertible. LOOP is if-convertible if: - it is innermost, - it has two or more basic blocks, - it has only one exit, - loop header is not the exit edge, - if its basic blocks and phi nodes are if convertible.
References data_reference::aux, dump_file, dump_flags, free(), free_data_refs(), free_dependence_relations(), loop::header, if_convertible_loop_p_1(), loop::inner, loop_exit_edge_p(), loop::num_nodes, refs, single_exit(), and basic_block_def::succs.
Referenced by tree_if_conversion().
|
static |
Return true when LOOP is if-convertible. This is a helper function for if_convertible_loop_p. REFS and DDRS are initialized and freed in if_convertible_loop_p.
References data_reference::aux, bb_with_exit_edge_p(), calculate_dominance_info(), CDI_DOMINATORS, compute_data_dependences_for_loop(), dump_file, dump_flags, get_loop_body_in_if_conv_order(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), if_convertible_bb_p(), if_convertible_phi_p(), if_convertible_stmt_p(), is_predicated(), loop::num_nodes, and predicate_bbs().
Referenced by if_convertible_loop_p().
|
static |
Return true when PHI is if-convertible. PHI is part of loop LOOP and it belongs to basic block BB. PHI is not if-convertible if: - it has more than 2 arguments. When the flag_tree_loop_if_convert_stores is not set, PHI is not if-convertible if: - a virtual PHI is immediately used in another PHI node, - there is a virtual PHI in a BB other than the loop->header.
References dump_file, dump_flags, gimple_phi_num_args(), gimple_phi_result(), loop::header, print_gimple_stmt(), and virtual_operand_p().
Referenced by if_convertible_loop_p_1().
|
static |
Return true when STMT is if-convertible. A statement is if-convertible if: - it is an if-convertible GIMPLE_ASSIGN, - it is a GIMPLE_LABEL or a GIMPLE_COND.
References dump_file, dump_flags, gimple_call_flags(), gimple_call_fndecl(), if_convertible_gimple_assign_stmt_p(), and print_gimple_stmt().
Referenced by if_convertible_loop_p_1().
|
static |
Returns a new SSA_NAME of type TYPE that is assigned the value of the expression EXPR. Inserts the statement created for this computation before GSI and leaves the iterator GSI at the same statement.
References gsi_insert_before(), GSI_SAME_STMT, and make_temp_ssa_name().
Referenced by predicate_mem_writes().
|
static |
Wrapper around gimple_could_trap_p refined for the needs of the if-conversion. Try to prove that the memory accesses of STMT could not trap in the innermost loop containing STMT.
References gimple_could_trap_p(), gimple_could_trap_p_1(), gimple_vuse(), and ifcvt_memrefs_wont_trap().
Referenced by if_convertible_gimple_assign_stmt_p().
|
static |
Return true when the memory references of STMT won't trap in the if-converted code. There are two things that we have to check for: - writes to memory occur to writable memory: if-conversion of memory writes transforms the conditional memory writes into unconditional writes, i.e. "if (cond) A[i] = foo" is transformed into "A[i] = cond ? foo : A[i]", and as the write to memory may not be executed at all in the original code, it may be a readonly memory. To check that A is not const-qualified, we check that there exists at least an unconditional write to A in the current function. - reads or writes to memory are valid memory accesses for every iteration. To check that the memory accesses are correctly formed and that we are allowed to read and write in these locations, we check that the memory accesses to be if-converted occur at every iteration unconditionally.
References memrefs_read_or_written_unconditionally(), and write_memrefs_written_at_least_once().
Referenced by ifcvt_could_trap_p().
|
inlinestatic |
Initializes to TRUE the predicate of basic block BB.
References basic_block_def::aux, set_bb_predicate(), and set_bb_predicate_gimplified_stmts().
Referenced by predicate_bbs(), and reset_bb_predicate().
|
static |
Insert in each basic block of LOOP the statements produced by the gimplification of the predicates.
References bb_predicate_gimplified_stmts(), gsi_after_labels(), gsi_end_p(), gsi_insert_seq_after(), gsi_insert_seq_before(), gsi_last_bb(), GSI_SAME_STMT, gsi_stmt(), is_predicated(), loop::num_nodes, reset_bb_predicate(), set_bb_predicate_gimplified_stmts(), and stmt_ends_bb_p().
Referenced by combine_blocks().
|
inlinestatic |
Returns true when BB has a predicate that is not trivial: true or NULL_TREE.
References bb_predicate(), and is_true_predicate().
Referenced by add_to_predicate_list(), if_convertible_loop_p_1(), and insert_gimplified_predicates().
|
inlinestatic |
Return true when COND is a true predicate.
References integer_onep().
Referenced by add_to_dst_predicate_list(), add_to_predicate_list(), is_predicated(), memrefs_read_or_written_unconditionally(), predicate_mem_writes(), and write_memrefs_written_at_least_once().
|
static |
Tree if-conversion pass management.
References basic_block_def::aux, cfun, changed, loop::force_vect, number_of_loops(), and tree_if_conversion().
gimple_opt_pass* make_pass_if_conversion | ( | ) |
|
static |
Returns true when the memory references of STMT are read or written unconditionally. In other words, this function returns true when for every data reference A in STMT there exist other accesses to a data reference with the same base with predicates that add up (OR-up) to the true predicate: this ensures that the data reference A is touched (read or written) on every iteration of the if-converted loop.
References bb_predicate(), DR_REF, DR_STMT, fold_or_predicates(), is_true_predicate(), and operand_equal_p().
Referenced by ifcvt_memrefs_wont_trap().
|
static |
Parses the predicate COND and returns its comparison code and operands OP0 and OP1.
References gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), invert_tree_comparison(), is_gimple_assign(), and tcc_comparison.
Referenced by fold_or_predicates().
|
static |
Return true when all predecessor blocks of BB are visited. The VISITED bitmap keeps track of the visited blocks.
References bitmap_bit_p(), basic_block_def::index, basic_block_def::preds, and edge_def::src.
Referenced by get_loop_body_in_if_conv_order().
|
static |
Replaces in LOOP all the scalar phi nodes other than those in the LOOP->header block with conditional modify expressions.
References find_phi_replacement_condition(), gsi_after_labels(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), loop::header, loop::num_nodes, predicate_scalar_phi(), release_phi_node(), and set_phi_nodes().
Referenced by combine_blocks().
|
static |
Returns true when the analysis of the predicates for all the basic blocks in LOOP succeeded. predicate_bbs first allocates the predicates of the basic blocks. These fields are then initialized with the tree expressions representing the predicates under which a basic block is executed in the LOOP. As the loop->header is executed at each iteration, it has the "true" predicate. Other statements executed under a condition are predicated with that condition, for example | if (x) | S1; | else | S2; S1 will be predicated with "x", and S2 will be predicated with "!x".
References add_to_dst_predicate_list(), add_to_predicate_list(), bb_predicate(), bb_predicate_gimplified_stmts(), extract_true_false_edges_from_block(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_location(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), loop::header, init_bb_predicate(), loop::latch, loop::num_nodes, reset_bb_predicate(), single_succ(), single_succ_p(), and unshare_expr().
Referenced by if_convertible_loop_p_1().
|
static |
Predicate each write to memory in LOOP. This function transforms control flow constructs containing memory writes of the form: | for (i = 0; i < N; i++) | if (cond) | A[i] = expr; into the following form that does not contain control flow: | for (i = 0; i < N; i++) | A[i] = cond ? expr : A[i]; The original CFG looks like this: | bb_0 | i = 0 | end_bb_0 | | bb_1 | if (i < N) goto bb_5 else goto bb_2 | end_bb_1 | | bb_2 | cond = some_computation; | if (cond) goto bb_3 else goto bb_4 | end_bb_2 | | bb_3 | A[i] = expr; | goto bb_4 | end_bb_3 | | bb_4 | goto bb_1 | end_bb_4 insert_gimplified_predicates inserts the computation of the COND expression at the beginning of the destination basic block: | bb_0 | i = 0 | end_bb_0 | | bb_1 | if (i < N) goto bb_5 else goto bb_2 | end_bb_1 | | bb_2 | cond = some_computation; | if (cond) goto bb_3 else goto bb_4 | end_bb_2 | | bb_3 | cond = some_computation; | A[i] = expr; | goto bb_4 | end_bb_3 | | bb_4 | goto bb_1 | end_bb_4 predicate_mem_writes is then predicating the memory write as follows: | bb_0 | i = 0 | end_bb_0 | | bb_1 | if (i < N) goto bb_5 else goto bb_2 | end_bb_1 | | bb_2 | if (cond) goto bb_3 else goto bb_4 | end_bb_2 | | bb_3 | cond = some_computation; | A[i] = cond ? expr : A[i]; | goto bb_4 | end_bb_3 | | bb_4 | goto bb_1 | end_bb_4 and finally combine_blocks removes the basic block boundaries making the loop vectorizable: | bb_0 | i = 0 | if (i < N) goto bb_5 else goto bb_1 | end_bb_0 | | bb_1 | cond = some_computation; | A[i] = cond ? expr : A[i]; | if (i < N) goto bb_5 else goto bb_4 | end_bb_1 | | bb_4 | goto bb_1 | end_bb_4
References bb_predicate(), fold_build_cond_expr(), force_gimple_operand_gsi_1(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_set_rhs1(), gimple_assign_single_p(), gimple_vdef(), gsi_end_p(), gsi_next(), GSI_SAME_STMT, gsi_start_bb(), gsi_stmt(), ifc_temp_var(), is_gimple_condexpr(), is_true_predicate(), loop::num_nodes, swap(), unshare_expr(), and update_stmt().
Referenced by combine_blocks().
|
static |
Replace a scalar PHI node with a COND_EXPR using COND as condition. This routine does not handle PHI nodes with more than two arguments. For example, S1: A = PHI <x1(1), x2(5)> is converted into, S2: A = cond ? x1 : x2; The generated code is inserted at GSI that points to the top of basic block's statement list. When COND is true, phi arg from TRUE_BB is selected.
References analyze_scalar_evolution(), chrec_contains_undetermined(), degenerate_phi_result(), dump_file, dump_flags, fold_build_cond_expr(), gimple_bb(), gimple_phi_arg_def(), gimple_phi_num_args(), gimple_phi_result(), gsi_insert_before(), GSI_SAME_STMT, print_gimple_stmt(), unshare_expr(), update_stmt(), and virtual_operand_p().
Referenced by predicate_all_scalar_phis().
|
static |
Remove all GIMPLE_CONDs and GIMPLE_LABELs of all the basic blocks other than the exit and latch of the LOOP. Also resets the GIMPLE_DEBUG information.
References bb_with_exit_edge_p(), gimple_debug_bind_p(), gimple_debug_bind_reset_value(), gsi_end_p(), gsi_next(), gsi_remove(), gsi_start_bb(), gsi_stmt(), loop::latch, loop::num_nodes, and update_stmt().
Referenced by combine_blocks().
|
inlinestatic |
Free the predicate of BB and reinitialize it with the true predicate.
References free_bb_predicate(), and init_bb_predicate().
Referenced by add_to_predicate_list(), insert_gimplified_predicates(), and predicate_bbs().
|
inlinestatic |
Sets the gimplified predicate COND for basic block BB.
References basic_block_def::aux, and is_gimple_condexpr().
Referenced by add_to_predicate_list(), and init_bb_predicate().
|
inlinestatic |
Sets the sequence of statements STMTS of the gimplification of the predicate for basic block BB.
References basic_block_def::aux.
Referenced by init_bb_predicate(), and insert_gimplified_predicates().
|
static |
If-convert LOOP when it is legal. For the moment this pass has no profitability analysis. Returns true when something changed.
References cfun, changed, combine_blocks(), dbg_cnt(), free(), free_bb_predicate(), if_convertible_loop_p(), mark_virtual_operands_for_renaming(), and loop::num_nodes.
Referenced by main_tree_if_conversion().
|
static |
Returns true when the memory references of STMT are unconditionally written. In other words, this function returns true when for every data reference A written in STMT, there exist other writes to the same data reference with predicates that add up (OR-up) to the true predicate: this ensures that the data reference A is written on every iteration of the if-converted loop.
References bb_predicate(), DR_IS_WRITE, DR_STMT, fold_or_predicates(), is_true_predicate(), and same_data_refs_base_objects().
Referenced by ifcvt_memrefs_wont_trap().
|
static |
@verbatim If-conversion for vectorizer.
Copyright (C) 2004-2013 Free Software Foundation, Inc. Contributed by Devang Patel dpate l@ap ple.c om
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
This pass implements a tree level if-conversion of loops. Its initial goal is to help the vectorizer to vectorize loops with conditions. A short description of if-conversion: o Decide if a loop is if-convertible or not. o Walk all loop basic blocks in breadth first order (BFS order). o Remove conditional statements (at the end of basic block) and propagate condition into destination basic blocks' predicate list. o Replace modify expression with conditional modify expression using current basic block's condition. o Merge all basic blocks o Replace phi nodes with conditional modify expr o Merge all basic blocks into header Sample transformation: INPUT ----- # i_23 = PHI <0(0), i_18(10)>; <L0>:; j_15 = A[i_23]; if (j_15 > 41) goto <L1>; else goto <L17>; <L17>:; goto <bb 3> (<L3>); <L1>:; # iftmp.2_4 = PHI <0(8), 42(2)>; <L3>:; A[i_23] = iftmp.2_4; i_18 = i_23 + 1; if (i_18 <= 15) goto <L19>; else goto <L18>; <L19>:; goto <bb 1> (<L0>); <L18>:; OUTPUT ------ # i_23 = PHI <0(0), i_18(10)>; <L0>:; j_15 = A[i_23]; <L3>:; iftmp.2_4 = j_15 > 41 ? 42 : 0; A[i_23] = iftmp.2_4; i_18 = i_23 + 1; if (i_18 <= 15) goto <L19>; else goto <L18>; <L19>:; goto <bb 1> (<L0>); <L18>:;
List of basic blocks in if-conversion-suitable order.