diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-21 07:24:34 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-21 07:24:34 +0000 |
commit | 7e3cc6817ae6be36340eb0c1978c1b3210cab69e (patch) | |
tree | 1ae11d72157fada15be9c9e63cd5c9c48811abca /gcc/loop-iv.c | |
parent | a195a2e0542f43ead546c488f0f7e687d2837570 (diff) | |
download | gcc-7e3cc6817ae6be36340eb0c1978c1b3210cab69e.tar.gz |
gcc:
2005-07-21 Paolo Bonzini <bonzini@gnu.org>
Zdenek Dvorak <dvorakz@suse.cz>
PR tree-optimization/19210
* common.opt (Wunsafe-loop-optimizations, funsafe-loop-optimizations):
New.
* Makefile.in (tree-ssa-loop-niter.o): Depend intl.o.
* loop-iv.c (get_simple_loop_desc): If -funsafe-loop-optimizations,
rely on unproven assumptions.
* predict.c (predict_loops): Adjust call to number_of_iterations_exit.
* tree-flow.h (number_of_iterations_exit): Add final parameter.
* tree-scalar-evolution.c (number_of_iterations_in_loop): Adjust call
to number_of_iterations_exit.
* tree-ssa-loop-ivcanon.c (empty_loop_p): Likewise.
* tree-ssa-loop-ivopts.c (niter_for_exit): Likewise.
* tree-ssa-loop-niter.c (find_loop_niter,
estimate_numbers_of_iterations_loop): Likewise.
(number_of_iterations_exit): Honor the new options.
* doc/invoke.texi (Wunsafe-loop-optimizations,
funsafe-loop-optimizations): Document them.
gcc/testsuite:
2005-07-21 Paolo Bonzini <bonzini@gnu.org>
* gcc.dg/tree-ssa/pr19210-1.c: New.
* gcc.dg/tree-ssa/pr19210-2.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102225 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-iv.c')
-rw-r--r-- | gcc/loop-iv.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index 48bae0bd954..7c7a5de0a55 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -57,7 +57,9 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "basic-block.h" #include "cfgloop.h" #include "expr.h" +#include "intl.h" #include "output.h" +#include "toplev.h" /* The insn information. */ @@ -2692,6 +2694,41 @@ get_simple_loop_desc (struct loop *loop) find_simple_exit (loop, desc); loop->aux = desc; + if (desc->simple_p && (desc->assumptions || desc->infinite)) + { + const char *wording; + + /* Assume that no overflow happens and that the loop is finite. + We already warned at the tree level if we ran optimizations there. */ + if (!flag_tree_loop_optimize && warn_unsafe_loop_optimizations) + { + if (desc->infinite) + { + wording = + flag_unsafe_loop_optimizations + ? N_("assuming that the loop is not infinite") + : N_("cannot optimize possibly infinite loops"); + warning (OPT_Wunsafe_loop_optimizations, "%s", + gettext (wording)); + } + if (desc->assumptions) + { + wording = + flag_unsafe_loop_optimizations + ? N_("assuming that the loop counter does not overflow") + : N_("cannot optimize loop, the loop counter may overflow"); + warning (OPT_Wunsafe_loop_optimizations, "%s", + gettext (wording)); + } + } + + if (flag_unsafe_loop_optimizations) + { + desc->assumptions = NULL_RTX; + desc->infinite = NULL_RTX; + } + } + return desc; } |