Patchwork Fix my change to unroll_loop_constant_iterations

login
register
mail settings
Submitter Jan Hubicka
Date Oct. 9, 2012, 8:31 a.m.
Message ID <20121009083115.GA32592@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/190241/
State New
Headers show

Comments

Jan Hubicka - Oct. 9, 2012, 8:31 a.m.
H,
I hope this change is responsible for today misoptimizations of SPEC at -O3.
While updating unroll_loop_constant_iterations and fighting with double_int
operations I made two trivial mistakes.

I am bootstrapping/regtesting the following and will commit it as obvious if
it passes.

Honza

	* loop-unroll.c (unroll_loop_constant_iterations): Fix previous patch.

Patch

Index: loop-unroll.c
===================================================================
--- loop-unroll.c	(revision 192239)
+++ loop-unroll.c	(working copy)
@@ -740,6 +740,7 @@  unroll_loop_constant_iterations (struct
   	    apply_opt_in_copies (opt_info, exit_mod + 1, false, false);
 
 	  desc->niter -= exit_mod + 1;
+	  loop->nb_iterations_upper_bound -= double_int::from_uhwi (exit_mod + 1);
 	  if (loop->any_estimate
 	      && double_int::from_uhwi (exit_mod + 1).ule
 	           (loop->nb_iterations_estimate))
@@ -795,12 +796,12 @@  unroll_loop_constant_iterations (struct
 
   desc->niter /= max_unroll + 1;
   loop->nb_iterations_upper_bound
-    = loop->nb_iterations_upper_bound.udiv (double_int::from_uhwi (exit_mod
+    = loop->nb_iterations_upper_bound.udiv (double_int::from_uhwi (max_unroll
 								   + 1),
 					    FLOOR_DIV_EXPR);
   if (loop->any_estimate)
     loop->nb_iterations_estimate
-      = loop->nb_iterations_estimate.udiv (double_int::from_uhwi (exit_mod
+      = loop->nb_iterations_estimate.udiv (double_int::from_uhwi (max_unroll
 							          + 1),
 				           FLOOR_DIV_EXPR);
   desc->niter_expr = GEN_INT (desc->niter);