GCC Middle and Back End API Reference
|
Functions | |
rtx | doloop_condition_get () |
static bool | doloop_valid_p () |
static bool | add_test () |
static void | doloop_modify (struct loop *loop, struct niter_desc *desc, rtx doloop_seq, rtx condition, rtx count) |
static bool | doloop_optimize () |
void | doloop_optimize_loops () |
|
static |
Adds test of COND jumping to DEST on edge *E and set *E to the new fallthru edge. If the condition is always false, do not do anything. If it is always true, redirect E to DEST and return false. In all other cases, true is returned.
References add_reg_note(), any_uncondjump_p(), block_label(), delete_insn(), do_compare_rtx_and_jump(), end_sequence(), basic_block_def::flags, force_operand(), get_insns(), get_last_insn(), make_edge(), redirect_edge_and_branch_force(), single_succ_edge(), split_edge_and_insert(), and start_sequence().
Referenced by doloop_modify().
rtx doloop_condition_get | ( | ) |
@verbatim Perform doloop optimizations
Copyright (C) 2004-2013 Free Software Foundation, Inc. Based on code by Michael P. Hayes (m.hay) es@e lec.c ante rbury .ac. nz
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 module is used to modify loops with a determinable number of iterations to use special low-overhead looping instructions. It first validates whether the loop is well behaved and has a determinable number of iterations (either at compile or run-time). It then modifies the loop to use a low-overhead looping pattern as follows: 1. A pseudo register is allocated as the loop iteration counter. 2. The number of loop iterations is calculated and is stored in the loop counter. 3. At the end of the loop, the jump insn is replaced by the doloop_end pattern. The compare must remain because it might be used elsewhere. If the loop-variable or condition register are used elsewhere, they will be eliminated by flow. 4. An optional doloop_begin pattern is inserted at the top of the loop. TODO The optimization should only performed when either the biv used for exit condition is unused at all except for the exit test, or if we do not have to change its value, since otherwise we have to add a new induction variable, which usually will not pay up (unless the cost of the doloop pattern is somehow extremely lower than the cost of compare & jump, or unless the bct register cannot be used for anything else but doloop -- ??? detect these cases).
Return the loop termination condition for PATTERN or zero if it is not a decrement and branch jump insn.
References pc_rtx, prev_nondebug_insn(), and SET.
|
static |
Modify the loop to use the low-overhead looping insn where LOOP describes the loop, DESC describes the number of iterations of the loop, and DOLOOP_INSN is the low-overhead looping insn to emit at the end of the loop. CONDITION is the condition separated from the DOLOOP_SEQ. COUNT is the number of iterations of the LOOP.
References add_reg_note(), add_test(), block_label(), CDI_DOMINATORS, niter_desc::const_iter, convert_move(), copy_rtx(), basic_block_def::count, delete_basic_block(), delete_insn(), edge_def::dest, dump_file, emit_insn(), emit_insn_after(), emit_jump_insn_after(), end_sequence(), find_reg_note(), double_int::fits_shwi(), edge_def::flags, force_operand(), basic_block_def::frequency, get_insns(), get_loop_level(), HOST_WIDEST_INT_PRINT_DEC, niter_desc::in_edge, loop_preheader_edge(), max_loop_iterations(), niter_desc::niter, niter_desc::niter_expr, niter_desc::noloop_assumptions, niter_desc::out_edge, basic_block_def::preds, edge_def::probability, recompute_dominator(), redirect_edge_and_branch_force(), set_immediate_dominator(), simplify_gen_binary(), single_succ_edge(), split_edge(), edge_def::src, start_sequence(), double_int::to_shwi(), and double_int::ule().
Referenced by doloop_optimize().
|
static |
Process loop described by LOOP validating that the loop is suitable for conversion to use a low overhead looping instruction, replacing the jump insn where suitable. Returns true if the loop was successfully modified.
References block_label(), niter_desc::const_iter, contains_no_active_insn_p(), copy_rtx(), count, basic_block_def::count, edge_def::dest, doloop_condition_get(), doloop_modify(), doloop_valid_p(), dump_file, expected_loop_iterations(), double_int::fits_shwi(), double_int::from_shwi(), gen_reg_rtx(), get_loop_level(), get_simple_loop_desc(), loop::header, HOST_WIDE_INT, niter_desc::in_edge, iv_analysis_loop_init(), loop::latch, lowpart_subreg(), max_loop_iterations(), niter_desc::mode, niter_desc::niter, niter_desc::niter_expr, loop::num, optimize_loop_for_speed_p(), set_src_cost(), simplify_gen_unary(), double_int::to_shwi(), double_int::ule(), and word_mode.
Referenced by doloop_optimize_loops().
void doloop_optimize_loops | ( | void | ) |
This is the main entry point. Process all loops using doloop_optimize.
References doloop_optimize(), iv_analysis_done(), and verify_loop_structure().
Referenced by rtl_doloop().
|
static |
Return nonzero if the loop specified by LOOP is suitable for the use of special low-overhead looping instructions. DESC describes the number of iterations of the loop.
References niter_desc::assumptions, dump_file, free(), get_loop_body(), niter_desc::infinite, loop::num_nodes, niter_desc::simple_p, and targetm.
Referenced by doloop_optimize().