diff mbox

[GCC/02] Remove -funsafe-loop-optimizations option.

Message ID HE1PR0801MB175538AF54BBD519BB0F4F7AE7090@HE1PR0801MB1755.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng July 21, 2016, 4:49 p.m. UTC
Hi,
This patch removes support for -funsafe-loop-optimizations on both GIMPLE and RTL level by marking it as ignored.
Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin

2016-07-20  Bin Cheng  <bin.cheng@arm.com>

	* common.opt (funsafe-loop-optimizations): Mark ignore.
	* doc/invoke.texi (funsafe-loop-optimizations): Remove.
	* loop-iv.c (get_simple_loop_desc): Remove unsafe-loop-optimizations
	related code.
	* tree-ssa-loop-niter.c (finite_loop_p): Ditto.
	* config/bfin/bfin.c (bfin_can_use_doloop_p): Ditto.

Comments

Richard Biener July 22, 2016, 11:41 a.m. UTC | #1
On Thu, Jul 21, 2016 at 6:49 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This patch removes support for -funsafe-loop-optimizations on both GIMPLE and RTL level by marking it as ignored.
> Bootstrap and test on x86_64.  Is it OK?

Ok.

Richard.

> Thanks,
> bin
>
> 2016-07-20  Bin Cheng  <bin.cheng@arm.com>
>
>         * common.opt (funsafe-loop-optimizations): Mark ignore.
>         * doc/invoke.texi (funsafe-loop-optimizations): Remove.
>         * loop-iv.c (get_simple_loop_desc): Remove unsafe-loop-optimizations
>         related code.
>         * tree-ssa-loop-niter.c (finite_loop_p): Ditto.
>         * config/bfin/bfin.c (bfin_can_use_doloop_p): Ditto.
diff mbox

Patch

diff --git a/gcc/common.opt b/gcc/common.opt
index b56ba47..8a292ed 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2507,8 +2507,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
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 75ddcf0..b6edf2c 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9a4db38..3041c18 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -414,7 +414,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}
@@ -6818,15 +6818,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
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index 57fb8c1..b3d41604 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -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;
 }
 
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 48947f0..2061eafa 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -2412,8 +2412,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))
     {