GCC Middle and Back End API Reference
tree-ssa-loop-ch.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tm_p.h"
#include "basic-block.h"
#include "gimple.h"
#include "gimple-ssa.h"
#include "tree-cfg.h"
#include "tree-into-ssa.h"
#include "tree-pass.h"
#include "cfgloop.h"
#include "tree-inline.h"
#include "flags.h"
#include "tree-ssa-threadedge.h"
Include dependency graph for tree-ssa-loop-ch.c:

Functions

static bool should_duplicate_loop_header_p (basic_block header, struct loop *loop, int *limit)
static bool do_while_loop_p ()
static unsigned int copy_loop_headers ()
static bool gate_ch ()
gimple_opt_passmake_pass_ch ()

Function Documentation

static unsigned int copy_loop_headers ( )
static

For all loops, copy the condition at the end of the loop body in front of the loop. This is beneficial since it increases efficiency of code motion optimizations. It also saves one jump on entry to the loop.

     Copy at most 20 insns.   
     If the loop is already a do-while style one (either because it was
     written as such, or because jump threading transformed it into one),
     we might be in fact peeling the first iteration of the loop.  This
     in general is not a good idea.   
     Iterate the header copying up to limit; this takes care of the cases
     like while (a && b) {...}, where we want to have both of the conditions
     copied.  TODO – handle while (a || b) - like cases, by not requiring
     the header to have just a single successor and copying up to
     postdominator.   
         Find a successor of header that is inside a loop; i.e. the new
         header after the condition is copied.   
     Ensure that the header will have just the latch as a predecessor
     inside the loop.   
     If the loop has the form "for (i = j; i < j + 10; i++)" then
     this copying can introduce a case where we rely on undefined
     signed overflow to eliminate the preheader condition, because
     we assume that "j < j + 10" is true.  We don't want to warn
     about that case for -Wstrict-overflow, because in general we
     don't warn about overflow involving loops.  Prevent the
     warning by setting the no_warning flag in the condition.   
     Ensure that the latch and the preheader is simple (we know that they
     are not now, since there was the loop exit condition.   
static bool do_while_loop_p ( )
static

Checks whether LOOP is a do-while style loop.

If the latch of the loop is not empty, it is not a do-while loop.

 If the header contains just a condition, it is not a do-while loop.   
static bool gate_ch ( )
static
gimple_opt_pass* make_pass_ch ( )
static bool should_duplicate_loop_header_p ( basic_block  header,
struct loop loop,
int *  limit 
)
static

Loop header copying on trees. Copyright (C) 2004-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/. Duplicates headers of loops if they are small enough, so that the statements in the loop body are always executed when the loop is entered. This increases effectiveness of code motion optimizations, and reduces the need for loop preconditioning. Check whether we should duplicate HEADER of LOOP. At most *LIMIT instructions should be duplicated, limit is decreased by the actual amount.

 Do not copy one block more than once (we do not really want to do
 loop peeling here).   
 Loop header copying usually increases size of the code.  This used not to
 be true, since quite often it is possible to verify that the condition is
 satisfied in the first iteration and therefore to eliminate it.  Jump
 threading handles these cases now.   
 If this is not the original loop header, we want it to have just
 one predecessor in order to match the && pattern.   
 Approximately copy the conditions that used to be used in jump.c &ndash;
 at most 20 insns and no calls.