/* Induction variable canonicalization.
- Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
-
+ Copyright (C) 2004, 2005, 2007, 2008, 2010
+ 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/>. */
/* This pass detects the loops that iterate a constant number of times,
- adds a canonical induction variable (step -1, tested against 0)
+ adds a canonical induction variable (step -1, tested against 0)
and replaces the exit test. This enables the less powerful rtl
level analysis to use this information.
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
-#include "rtl.h"
#include "tm_p.h"
-#include "hard-reg-set.h"
#include "basic-block.h"
-#include "output.h"
-#include "diagnostic.h"
+#include "tree-pretty-print.h"
+#include "gimple-pretty-print.h"
#include "tree-flow.h"
#include "tree-dump.h"
#include "cfgloop.h"
#include "tree-pass.h"
-#include "ggc.h"
#include "tree-chrec.h"
#include "tree-scalar-evolution.h"
#include "params.h"
if (is_gimple_min_invariant (op))
return true;
-
+
/* We can still fold accesses to constant arrays when index is known. */
if (TREE_CODE (op) != SSA_NAME)
{
/* First make fast look if we see constant array inside. */
while (handled_component_p (base))
base = TREE_OPERAND (base, 0);
- if ((DECL_P (base)
- && TREE_STATIC (base)
- && TREE_READONLY (base)
- && (DECL_INITIAL (base)
- || (!DECL_EXTERNAL (base)
- && targetm.binds_local_p (base))))
+ if ((DECL_P (base) == VAR_DECL
+ && const_value_known_p (base))
|| CONSTANT_CLASS_P (base))
{
/* If so, see if we understand all the indices. */
fprintf (dump_file, "size: %i-%i, last_iteration: %i-%i\n", size->overall,
size->eliminated_by_peeling, size->last_iteration,
size->last_iteration_eliminated_by_peeling);
-
+
free (body);
}
}
/* Tries to unroll LOOP completely, i.e. NITER times.
- UL determines which loops we are allowed to unroll.
+ UL determines which loops we are allowed to unroll.
EXIT is the exit of the loop that should be eliminated. */
static bool
return false;
}
- for (i = 0; VEC_iterate (edge, to_remove, i, e); i++)
+ FOR_EACH_VEC_ELT (edge, to_remove, i, e)
{
bool ok = remove_path (e);
gcc_assert (ok);
}
/* Adds a canonical induction variable to LOOP if suitable.
- CREATE_IV is true if we may create a new iv. UL determines
+ CREATE_IV is true if we may create a new iv. UL determines
which loops we are allowed to completely unroll. If TRY_EVAL is true, we try
- to determine the number of iterations of a loop by direct evaluation.
+ to determine the number of iterations of a loop by direct evaluation.
Returns true if cfg is changed. */
static bool
loop_iterator li;
struct loop *loop;
bool changed = false;
-
+
FOR_EACH_LOOP (li, loop, 0)
{
changed |= canonicalize_loop_induction_variables (loop,
struct loop *loop;
bool changed;
enum unroll_level ul;
+ int iteration = 0;
do
{
scev_reset ();
}
}
- while (changed);
+ while (changed
+ && ++iteration <= PARAM_VALUE (PARAM_MAX_UNROLL_ITERATIONS));
return 0;
}