/* Induction variable canonicalization.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GCC.
if (n_unroll)
{
- if (!flag_unroll_loops)
- return false;
-
old_cond = COND_EXPR_COND (cond);
COND_EXPR_COND (cond) = dont_exit;
modify_stmt (cond);
niter = fold (build2 (MINUS_EXPR, TREE_TYPE (niter), niter,
build_int_cst (TREE_TYPE (niter), 1)));
}
- else if (try_eval)
- niter = find_loop_niter_by_eval (loop, &exit);
-
- if (chrec_contains_undetermined (niter)
- || TREE_CODE (niter) != INTEGER_CST)
- return false;
+ else
+ {
+ /* If the loop has more than one exit, try checking all of them
+ for # of iterations determinable through scev. */
+ if (!loop->single_exit)
+ niter = find_loop_niter (loop, &exit);
+
+ /* Finally if everything else fails, try brute force evaluation. */
+ if (try_eval
+ && (chrec_contains_undetermined (niter)
+ || TREE_CODE (niter) != INTEGER_CST))
+ niter = find_loop_niter_by_eval (loop, &exit);
+
+ if (chrec_contains_undetermined (niter)
+ || TREE_CODE (niter) != INTEGER_CST)
+ return false;
+ }
if (dump_file && (dump_flags & TDF_DETAILS))
{
{
unsigned i;
struct loop *loop;
+ bool changed = false;
for (i = 1; i < loops->num; i++)
{
loop = loops->parray[i];
if (loop)
- canonicalize_loop_induction_variables (loops, loop, true, false, true);
+ changed |= canonicalize_loop_induction_variables (loops, loop,
+ true, false, true);
}
/* Clean up the information about numbers of iterations, since brute force
evaluation could reveal new information. */
scev_reset ();
-#if 0
- /* The necessary infrastructure is not in yet. */
if (changed)
cleanup_tree_cfg_loop ();
-#endif
}
/* Unroll LOOPS completely if they iterate just few times. */
unrolling might have invalidated it. */
scev_reset ();
-#if 0
- /* The necessary infrastructure is not in yet. */
if (changed)
cleanup_tree_cfg_loop ();
-#endif
}