GCC Middle and Back End API Reference
loop-doloop.c File 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 ()

Function Documentation

static bool add_test ( )
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.nosp@m.es@e.nosp@m.lec.c.nosp@m.ante.nosp@m.rbury.nosp@m..ac..nosp@m.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 void doloop_modify ( struct loop loop,
struct niter_desc desc,
rtx  doloop_seq,
rtx  condition,
rtx  count 
)
static
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 bool doloop_valid_p ( )
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().