GCC Middle and Back End API Reference
loop-init.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "regs.h"
#include "obstack.h"
#include "basic-block.h"
#include "cfgloop.h"
#include "tree-pass.h"
#include "flags.h"
#include "df.h"
#include "ggc.h"
#include "gimple.h"
#include "tree-ssa-loop-niter.h"
Include dependency graph for loop-init.c:

Functions

static void apply_loop_flags ()
void loop_optimizer_init ()
void loop_optimizer_finalize ()
unsigned fix_loop_structure ()
static bool gate_handle_loop2 ()
rtl_opt_passmake_pass_loop2 ()
static unsigned int rtl_loop_init ()
rtl_opt_passmake_pass_rtl_loop_init ()
static unsigned int rtl_loop_done ()
rtl_opt_passmake_pass_rtl_loop_done ()
static bool gate_rtl_move_loop_invariants ()
static unsigned int rtl_move_loop_invariants ()
rtl_opt_passmake_pass_rtl_move_loop_invariants ()
static bool gate_rtl_unswitch ()
static unsigned int rtl_unswitch ()
rtl_opt_passmake_pass_rtl_unswitch ()
static bool gate_rtl_unroll_and_peel_loops ()
static unsigned int rtl_unroll_and_peel_loops ()
rtl_opt_passmake_pass_rtl_unroll_and_peel_loops ()
static bool gate_rtl_doloop ()
static unsigned int rtl_doloop ()
rtl_opt_passmake_pass_rtl_doloop ()

Function Documentation

static void apply_loop_flags ( )
static

Loop optimizer initialization routines and RTL loop optimization passes. Copyright (C) 2002-2013 Free Software Foundation, Inc.

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/. Apply FLAGS to the loop state.

If the loops may have multiple latches, we cannot canonicalize
them further (and most of the loop manipulation functions will
not work).  However, we avoid modifying cfg, which some
passes may want.   
 Create pre-headers.   


 Force all latches to have only single successor.   
 Mark irreducible loops.   

References gcc_assert, LOOPS_HAVE_RECORDED_EXITS, and loops_state_set().

unsigned fix_loop_structure ( )

The structure of loops might have changed. Some loops might get removed (and their headers and latches were set to NULL), loop exists might get removed (thus the loop nesting may be wrong), and some blocks and edges were changed (so the information about bb –> loop mapping does not have to be correct). But still for the remaining loops the header dominates the latch, and loops did not get new subloops (new loops might possibly get created, but we are not interested in them). Fix up the mess.

If CHANGED_BBS is not NULL, basic blocks whose loop depth has changed are marked in it.

Returns the number of new discovered loops.

 We need exact and fast dominance info to be available.   
 Remember the depth of the blocks in the loop hierarchy, so that we can
 recognize blocks whose loop nesting relationship has changed.   
 Remove the dead loops from structures.  We start from the innermost
 loops, so that when we remove the loops, we know that the loops inside
 are preserved, and do not waste time relinking loops that will be
 removed later.   
     Detect the case that the loop is no longer present even though
     it wasn't marked for removal.
     ???  If we do that we can get away with not marking loops for
     removal at all.  And possibly avoid some spurious removals.   
     Remove the loop.   
 Remember the number of loops so we can return how many new loops
 flow_loops_find discovered.   
 Re-compute loop structure in-place.   
 Mark the blocks whose loop has changed.   
 Finally free deleted loops.   
 Apply flags to loops.   
static bool gate_handle_loop2 ( )
static

Gate for the RTL loop superpass. The actual passes are subpasses. See passes.c for more on that.

No longer preserve loops, remove them now.

static bool gate_rtl_doloop ( )
static

The doloop optimization.

static bool gate_rtl_move_loop_invariants ( )
static

Loop invariant code motion.

static bool gate_rtl_unroll_and_peel_loops ( )
static

Loop unswitching for RTL.

static bool gate_rtl_unswitch ( )
static

Loop unswitching for RTL.

void loop_optimizer_finalize ( void  )

Finalize loop structures.

If we should preserve loop structure, do not free it but clear flags that advanced properties are there as we are not preserving that in full.

 Clean up.   

References LOOP_CLOSED_SSA, LOOPS_HAVE_FALLTHRU_PREHEADERS, loops_state_clear(), and loops_state_set().

Referenced by analyze_function(), and move_unallocated_pseudos().

void loop_optimizer_init ( )

Initialize loop structures. This is used by the tree and RTL loop optimizers. FLAGS specify what properties to compute and/or ensure for loops.

     Find the loops.   
     Ensure that the dominators are computed, like flow_loops_find does.   
     Clear all flags.   
 Apply flags to loops.   
 Dump loops.   
rtl_opt_pass* make_pass_loop2 ( )
rtl_opt_pass* make_pass_rtl_doloop ( )
rtl_opt_pass* make_pass_rtl_loop_done ( )
rtl_opt_pass* make_pass_rtl_loop_init ( )
rtl_opt_pass* make_pass_rtl_move_loop_invariants ( )
rtl_opt_pass* make_pass_rtl_unroll_and_peel_loops ( )
rtl_opt_pass* make_pass_rtl_unswitch ( )
static unsigned int rtl_doloop ( )
static
static unsigned int rtl_loop_done ( )
static

Finalization of the RTL loop passes.

No longer preserve loops, remove them now.

References opt_pass::execute(), and rtl_opt_pass::rtl_opt_pass().

static unsigned int rtl_loop_init ( )
static

Initialization of the RTL loop passes.

References opt_pass::execute(), and rtl_opt_pass::rtl_opt_pass().

static unsigned int rtl_move_loop_invariants ( )
static
static unsigned int rtl_unroll_and_peel_loops ( )
static
static unsigned int rtl_unswitch ( )
static