diff mbox

loop-unroll.c TLC 1/4

Message ID 20121020142153.GA5141@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Oct. 20, 2012, 2:21 p.m. UTC
Hi,
the TLC path I sent last week became outdated for few reaons.  I decided to split it up for easier reviewing.
This is simple correcntess issue I am comitting as obvoius - my last update to loop-iv missed the fact
that loop-iv bounds may depend on further conditions. In that case we can not record them as hard upper
bound.
I also double checked that we actually use the bounds only when they are unconditional, so I hopefully
did not introduced any missed optimization.

Bootstrapped/regtested x86_64-linux, comitted as obvoius.

	* loop-iv.c (iv_number_of_iterations): Record the upper bound
	only if there are no further conditions on it.
diff mbox

Patch

Index: loop-iv.c
===================================================================
--- loop-iv.c	(revision 192632)
+++ loop-iv.c	(working copy)
@@ -2593,8 +2593,10 @@  iv_number_of_iterations (struct loop *lo
 			 ? iv0.base
 			 : mode_mmin);
 	  max = (up - down) / inc + 1;
-	  record_niter_bound (loop, double_int::from_uhwi (max),
-			      false, true);
+	  if (!desc->infinite
+	      && !desc->assumptions)
+	    record_niter_bound (loop, double_int::from_uhwi (max),
+			        false, true);
 
 	  if (iv0.step == const0_rtx)
 	    {
@@ -2806,15 +2808,19 @@  iv_number_of_iterations (struct loop *lo
 
       desc->const_iter = true;
       desc->niter = val & GET_MODE_MASK (desc->mode);
-      record_niter_bound (loop, double_int::from_uhwi (desc->niter),
-			  false, true);
+      if (!desc->infinite
+	  && !desc->assumptions)
+        record_niter_bound (loop, double_int::from_uhwi (desc->niter),
+			    false, true);
     }
   else
     {
       max = determine_max_iter (loop, desc, old_niter);
       gcc_assert (max);
-      record_niter_bound (loop, double_int::from_uhwi (max),
-			  false, true);
+      if (!desc->infinite
+	  && !desc->assumptions)
+	record_niter_bound (loop, double_int::from_uhwi (max),
+			    false, true);
 
       /* simplify_using_initial_values does a copy propagation on the registers
 	 in the expression for the number of iterations.  This prolongs life