This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Adjust nb_iterations_upper_bound in loop header copying


This patch decrements nb_iterations_upper_bound by one after we copied
the loop header.  This allows niter + 1 to more often not overflow.

Bootstrapped and tested on x86_64-unknown-linux-gnu, installed to trunk.

Richard.

2013-11-21  Richard Biener  <rguenther@suse.de>

	* tree-ssa-loop-ch.c (copy_loop_headers): Decrement
	nb_iterations_upper_bound by one.

Index: gcc/tree-ssa-loop-ch.c
===================================================================
--- gcc/tree-ssa-loop-ch.c	(revision 205097)
+++ gcc/tree-ssa-loop-ch.c	(working copy)
@@ -243,6 +243,16 @@ copy_loop_headers (void)
 	 are not now, since there was the loop exit condition.  */
       split_edge (loop_preheader_edge (loop));
       split_edge (loop_latch_edge (loop));
+
+      /* We peeled off one iteration of the loop thus we can lower
+	 the maximum number of iterations if we have a previously
+	 recorded value for that.  */
+      double_int max;
+      if (get_max_loop_iterations (loop, &max))
+	{
+	  max -= double_int_one;
+	  loop->nb_iterations_upper_bound = max;
+	}
     }
 
   update_ssa (TODO_update_ssa);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]