@@ -625,8 +625,8 @@ Common Var(warn_null_dereference) Warning
Warn if dereferencing a NULL pointer may lead to erroneous or undefined behavior.
Wunsafe-loop-optimizations
-Common Var(warn_unsafe_loop_optimizations) Warning
-Warn if the loop cannot be optimized due to nontrivial assumptions.
+Common Ignore
+Does nothing. Preserved for backward compatibility.
Wmissing-noreturn
Common Warning Alias(Wsuggest-attribute=noreturn)
@@ -2500,8 +2500,8 @@ Perform loop unrolling for all loops.
; that control loops do not overflow and that the loops with nontrivial
; exit condition are not infinite
funsafe-loop-optimizations
-Common Report Var(flag_unsafe_loop_optimizations) Optimization
-Allow loop optimizations to assume that the loops behave in normal way.
+Common Ignore
+Does nothing. Preserved for backward compatibility.
fassociative-math
Common Report Var(flag_associative_math) SetByCombined Optimization
@@ -3375,10 +3375,7 @@ bfin_can_use_doloop_p (const widest_int &, const widest_int &iterations_max,
/* Due to limitations in the hardware (an initial loop count of 0
does not loop 2^32 times) we must avoid to generate a hardware
loops when we cannot rule out this case. */
- if (!flag_unsafe_loop_optimizations
- && wi::geu_p (iterations_max, 0xFFFFFFFF))
- return false;
- return true;
+ return (wi::ltu_p (iterations_max, 0xFFFFFFFF));
}
/* Increment the counter for the number of loop instructions in the
@@ -302,8 +302,7 @@ Objective-C and Objective-C++ Dialects}.
-Wswitch -Wswitch-bool -Wswitch-default -Wswitch-enum @gol
-Wswitch-unreachable -Wsync-nand @gol
-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
--Wtype-limits -Wundef @gol
--Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations @gol
+-Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas @gol
-Wunsuffixed-float-constants -Wunused -Wunused-function @gol
-Wunused-label -Wunused-local-typedefs -Wunused-parameter @gol
-Wno-unused-result -Wunused-value @gol -Wunused-variable @gol
@@ -414,7 +413,7 @@ Objective-C and Objective-C++ Dialects}.
-ftree-switch-conversion -ftree-tail-merge -ftree-ter @gol
-ftree-vectorize -ftree-vrp -funconstrained-commons @gol
-funit-at-a-time -funroll-all-loops -funroll-loops @gol
--funsafe-loop-optimizations -funsafe-math-optimizations -funswitch-loops @gol
+-funsafe-math-optimizations -funswitch-loops @gol
-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
-fweb -fwhole-program -fwpa -fuse-linker-plugin @gol
--param @var{name}=@var{value}
@@ -4986,14 +4985,6 @@ If the stack usage is (partly) dynamic and not bounded, it's:
@end smallexample
@end itemize
-@item -Wunsafe-loop-optimizations
-@opindex Wunsafe-loop-optimizations
-@opindex Wno-unsafe-loop-optimizations
-Warn if the loop cannot be optimized because the compiler cannot
-assume anything on the bounds of the loop indices. With
-@option{-funsafe-loop-optimizations} warn if the compiler makes
-such assumptions.
-
@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
@opindex Wno-pedantic-ms-format
@opindex Wpedantic-ms-format
@@ -6817,15 +6808,6 @@ number of iterations of a loop are used to guide loop unrolling and peeling
and loop exit test optimizations.
This option is enabled by default.
-@item -funsafe-loop-optimizations
-@opindex funsafe-loop-optimizations
-This option tells the loop optimizer to assume that loop indices do not
-overflow, and that loops with nontrivial exit condition are not
-infinite. This enables a wider range of loop optimizations even if
-the loop optimizer itself cannot prove that these assumptions are valid.
-If you use @option{-Wunsafe-loop-optimizations}, the compiler warns you
-if it finds this kind of loop.
-
@item -funconstrained-commons
@opindex funconstrained-commons
This option tells the compiler that variables declared in common blocks
@@ -2820,7 +2820,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
exits = get_loop_exit_edges (loop);
FOR_EACH_VEC_ELT (exits, j, ex)
- if (number_of_iterations_exit (loop, ex, &niter_desc, false)
+ if (number_of_iterations_exit (loop, ex, &niter_desc)
&& !is_gimple_min_invariant (niter_desc.niter))
{
predicate will_be_nonconstant
@@ -3027,42 +3027,6 @@ get_simple_loop_desc (struct loop *loop)
iv_analysis_loop_init (loop);
find_simple_exit (loop, desc);
loop->simple_loop_desc = 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 && single_exit (loop))
- {
- desc->assumptions = NULL_RTX;
- desc->infinite = NULL_RTX;
- }
- }
-
return desc;
}
@@ -1774,7 +1774,7 @@ predict_loops (void)
}
predict_extra_loop_exits (ex);
- if (number_of_iterations_exit (loop, ex, &niter_desc, false, false))
+ if (number_of_iterations_exit (loop, ex, &niter_desc, false))
niter = niter_desc.niter;
if (!niter || TREE_CODE (niter_desc.niter) != INTEGER_CST)
niter = loop_niter_by_eval (loop, ex);
deleted file mode 100644
@@ -1,29 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -Wunsafe-loop-optimizations" } */
-extern void g(void);
-
-void
-f (unsigned n)
-{
- unsigned k;
- for(k = 0;k <= n;k++) /* { dg-warning "cannot optimize.*infinite loops" } */
- g();
-
- for(k = 0;k <= n;k += 4) /* { dg-warning "cannot optimize.*overflow" } */
- g();
-
- /* We used to get warning for this loop. However, since then # of iterations
- analysis improved, and we can now prove that this loop does not verflow.
- This is because the only case when it would overflow is if n = ~0 (since
- ~0 is divisible by 5), and this cannot be the case, since when we got
- here, the previous loop exited, thus there exists k > n. */
- for(k = 5;k <= n;k += 5)
- g();
-
- /* So we need the following loop, instead. */
- for(k = 4;k <= n;k += 5) /* { dg-warning "cannot optimize.*overflow" } */
- g();
-
- for(k = 15;k >= n;k--) /* { dg-warning "cannot optimize.*infinite" } */
- g();
-}
deleted file mode 100644
@@ -1,29 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -funsafe-loop-optimizations -Wunsafe-loop-optimizations" } */
-extern void g(void);
-
-void
-f (unsigned n)
-{
- unsigned k;
- for(k = 0;k <= n;k++) /* { dg-warning "assuming.*not infinite" } */
- g();
-
- for(k = 5;k <= n;k += 4) /* { dg-warning "assuming.*not overflow" } */
- g();
-
- /* We used to get warning for this loop. However, since then # of iterations
- analysis improved, and we can now prove that this loop does not verflow.
- This is because the only case when it would overflow is if n = ~0 (since
- ~0 is divisible by 5), and this cannot be the case, since when we got
- here, the previous loop exited, thus there exists k > n. */
- for(k = 5;k <= n;k += 5)
- g();
-
- for(k = 4;k <= n;k += 5) /* { dg-warning "assuming.*not overflow" } */
- g();
-
- for(k = 15;k >= n;k--) /* { dg-warning "assuming.*not infinite" } */
- g();
-
-}
@@ -2609,7 +2609,7 @@ try_get_loop_niter (loop_p loop, struct tree_niter_desc *niter)
/* We need to know # of iterations, and there should be no uses of values
defined inside loop outside of it, unless the values are invariants of
the loop. */
- if (!number_of_iterations_exit (loop, exit, niter, false))
+ if (!number_of_iterations_exit (loop, exit, niter))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " FAILED: number of iterations not known\n");
@@ -3076,7 +3076,7 @@ number_of_latch_executions (struct loop *loop)
res = chrec_dont_know;
exit = single_exit (loop);
- if (exit && number_of_iterations_exit (loop, exit, &niter_desc, false))
+ if (exit && number_of_iterations_exit (loop, exit, &niter_desc))
{
may_be_zero = niter_desc.may_be_zero;
res = niter_desc.niter;
@@ -571,8 +571,7 @@ remove_redundant_iv_tests (struct loop *loop)
/* Only when we know the actual number of iterations, not
just a bound, we can remove the exit. */
- if (!number_of_iterations_exit (loop, exit_edge,
- &niter, false, false)
+ if (!number_of_iterations_exit (loop, exit_edge, &niter, false)
|| !integer_onep (niter.assumptions)
|| !integer_zerop (niter.may_be_zero)
|| !niter.niter
@@ -1019,9 +1019,8 @@ niter_for_exit (struct ivopts_data *data, edge exit)
names that appear in phi nodes on abnormal edges, so that we do not
create overlapping life ranges for them (PR 27283). */
desc = XNEW (struct tree_niter_desc);
- if (!number_of_iterations_exit (data->current_loop,
- exit, desc, true)
- || contains_abnormal_ssa_name_p (desc->niter))
+ if (!number_of_iterations_exit (data->current_loop, exit, desc)
+ || contains_abnormal_ssa_name_p (desc->niter))
{
XDELETE (desc);
desc = NULL;
@@ -933,7 +933,7 @@ can_unroll_loop_p (struct loop *loop, unsigned factor,
if (!exit)
return false;
- if (!number_of_iterations_exit (loop, exit, niter, false)
+ if (!number_of_iterations_exit (loop, exit, niter)
|| niter->cmp == ERROR_MARK
/* Scalar evolutions analysis might have copy propagated
the abnormal ssa names into these expressions, hence
@@ -2322,7 +2322,7 @@ number_of_iterations_exit_assumptions (struct loop *loop, edge exit,
bool
number_of_iterations_exit (struct loop *loop, edge exit,
struct tree_niter_desc *niter,
- bool, bool every_iteration)
+ bool every_iteration)
{
if (!number_of_iterations_exit_assumptions (loop, exit, niter,
every_iteration))
@@ -2348,7 +2348,7 @@ find_loop_niter (struct loop *loop, edge *exit)
*exit = NULL;
FOR_EACH_VEC_ELT (exits, i, ex)
{
- if (!number_of_iterations_exit (loop, ex, &desc, false))
+ if (!number_of_iterations_exit (loop, ex, &desc))
continue;
if (integer_nonzerop (desc.may_be_zero))
@@ -2404,8 +2404,6 @@ finite_loop_p (struct loop *loop)
widest_int nit;
int flags;
- if (flag_unsafe_loop_optimizations)
- return true;
flags = flags_from_decl_or_type (current_function_decl);
if ((flags & (ECF_CONST|ECF_PURE)) && !(flags & ECF_LOOPING_CONST_OR_PURE))
{
@@ -3751,7 +3749,7 @@ estimate_numbers_of_iterations_loop (struct loop *loop)
likely_exit = single_likely_exit (loop);
FOR_EACH_VEC_ELT (exits, i, ex)
{
- if (!number_of_iterations_exit (loop, ex, &niter_desc, false, false))
+ if (!number_of_iterations_exit (loop, ex, &niter_desc, false))
continue;
niter = niter_desc.niter;
@@ -25,7 +25,7 @@ extern tree simplify_using_initial_conditions (struct loop *,
tree, tree = NULL);
extern bool loop_only_exit_p (const struct loop *, const_edge);
extern bool number_of_iterations_exit (struct loop *, edge,
- struct tree_niter_desc *niter, bool,
+ struct tree_niter_desc *niter,
bool every_iteration = true);
extern bool number_of_iterations_exit_assumptions (struct loop *, edge,
struct tree_niter_desc *,