mirror of git://gcc.gnu.org/git/gcc.git
				
				
				
			re PR tree-optimization/58697 (wrong code (segfaults) at -O3)
PR tree-optimization/58697 * cfgloop.c (get_estimated_loop_iterations_int): Rename from estimated_loop_iterations_int. (max_stmt_executions_int): Call get_max_loop_iterations_int. (get_max_loop_iterations_int): New. HWINT version of get_max_loop_iterations. * cfgloop.h: Add prototypes. * loop-iv.c (find_simple_exit): call get_estimated_loop_iterations_int. * loop-unroll.c (decide_peel_once_rolling): Call get_estimated_loop_iterations_int. * tree-ssa-loop-niter.c (estimated_loop_iterations_int): Add back. * tree-ssa-loop-niter.h: Tweak prototypes. From-SVN: r203709
This commit is contained in:
		
							parent
							
								
									c22df64f91
								
							
						
					
					
						commit
						1ef8889345
					
				|  | @ -1,3 +1,18 @@ | ||||||
|  | 2013-10-16  Andrew MacLeod  <amacleod@redhat.com> | ||||||
|  | 	 | ||||||
|  | 	PR tree-optimization/58697 | ||||||
|  | 	* cfgloop.c (get_estimated_loop_iterations_int): Rename from  | ||||||
|  | 	estimated_loop_iterations_int. | ||||||
|  | 	(max_stmt_executions_int): Call get_max_loop_iterations_int. | ||||||
|  | 	(get_max_loop_iterations_int): New.  HWINT version of  | ||||||
|  | 	get_max_loop_iterations. | ||||||
|  | 	* cfgloop.h: Add prototypes. | ||||||
|  | 	* loop-iv.c (find_simple_exit): call get_estimated_loop_iterations_int. | ||||||
|  | 	* loop-unroll.c (decide_peel_once_rolling): Call  | ||||||
|  | 	get_estimated_loop_iterations_int. | ||||||
|  | 	* tree-ssa-loop-niter.c (estimated_loop_iterations_int): Add back. | ||||||
|  | 	* tree-ssa-loop-niter.h: Tweak prototypes. | ||||||
|  | 
 | ||||||
| 2013-10-16  David Malcolm  <dmalcolm@redhat.com> | 2013-10-16  David Malcolm  <dmalcolm@redhat.com> | ||||||
| 
 | 
 | ||||||
| 	* gengtype-parse.c (struct_field_seq): Ignore access-control | 	* gengtype-parse.c (struct_field_seq): Ignore access-control | ||||||
|  |  | ||||||
|  | @ -1815,12 +1815,12 @@ record_niter_bound (struct loop *loop, double_int i_bound, bool realistic, | ||||||
|     loop->nb_iterations_estimate = loop->nb_iterations_upper_bound; |     loop->nb_iterations_estimate = loop->nb_iterations_upper_bound; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Similar to estimated_loop_iterations, but returns the estimate only
 | /* Similar to get_estimated_loop_iterations, but returns the estimate only
 | ||||||
|    if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate |    if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate | ||||||
|    on the number of iterations of LOOP could not be derived, returns -1.  */ |    on the number of iterations of LOOP could not be derived, returns -1.  */ | ||||||
| 
 | 
 | ||||||
| HOST_WIDE_INT | HOST_WIDE_INT | ||||||
| estimated_loop_iterations_int (struct loop *loop) | get_estimated_loop_iterations_int (struct loop *loop) | ||||||
| { | { | ||||||
|   double_int nit; |   double_int nit; | ||||||
|   HOST_WIDE_INT hwi_nit; |   HOST_WIDE_INT hwi_nit; | ||||||
|  | @ -1842,7 +1842,7 @@ estimated_loop_iterations_int (struct loop *loop) | ||||||
| HOST_WIDE_INT | HOST_WIDE_INT | ||||||
| max_stmt_executions_int (struct loop *loop) | max_stmt_executions_int (struct loop *loop) | ||||||
| { | { | ||||||
|   HOST_WIDE_INT nit = max_loop_iterations_int (loop); |   HOST_WIDE_INT nit = get_max_loop_iterations_int (loop); | ||||||
|   HOST_WIDE_INT snit; |   HOST_WIDE_INT snit; | ||||||
| 
 | 
 | ||||||
|   if (nit == -1) |   if (nit == -1) | ||||||
|  | @ -1891,3 +1891,25 @@ get_max_loop_iterations (struct loop *loop, double_int *nit) | ||||||
|   *nit = loop->nb_iterations_upper_bound; |   *nit = loop->nb_iterations_upper_bound; | ||||||
|   return true; |   return true; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | /* Similar to get_max_loop_iterations, but returns the estimate only
 | ||||||
|  |    if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate | ||||||
|  |    on the number of iterations of LOOP could not be derived, returns -1.  */ | ||||||
|  | 
 | ||||||
|  | HOST_WIDE_INT | ||||||
|  | get_max_loop_iterations_int (struct loop *loop) | ||||||
|  | { | ||||||
|  |   double_int nit; | ||||||
|  |   HOST_WIDE_INT hwi_nit; | ||||||
|  | 
 | ||||||
|  |   if (!get_max_loop_iterations (loop, &nit)) | ||||||
|  |     return -1; | ||||||
|  | 
 | ||||||
|  |   if (!nit.fits_shwi ()) | ||||||
|  |     return -1; | ||||||
|  |   hwi_nit = nit.to_shwi (); | ||||||
|  | 
 | ||||||
|  |   return hwi_nit < 0 ? -1 : hwi_nit; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -740,8 +740,8 @@ loop_outermost (struct loop *loop) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| extern void record_niter_bound (struct loop *, double_int, bool, bool); | extern void record_niter_bound (struct loop *, double_int, bool, bool); | ||||||
| extern HOST_WIDE_INT estimated_loop_iterations_int (struct loop *); | extern HOST_WIDE_INT get_estimated_loop_iterations_int (struct loop *); | ||||||
| extern HOST_WIDE_INT max_loop_iterations_int (struct loop *); | extern HOST_WIDE_INT get_max_loop_iterations_int (struct loop *); | ||||||
| extern bool get_estimated_loop_iterations (struct loop *loop, double_int *nit); | extern bool get_estimated_loop_iterations (struct loop *loop, double_int *nit); | ||||||
| extern bool get_max_loop_iterations (struct loop *loop, double_int *nit); | extern bool get_max_loop_iterations (struct loop *loop, double_int *nit); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3001,9 +3001,9 @@ find_simple_exit (struct loop *loop, struct niter_desc *desc) | ||||||
|       	  fprintf (dump_file, "\n"); |       	  fprintf (dump_file, "\n"); | ||||||
| 
 | 
 | ||||||
| 	  fprintf (dump_file, "  upper bound: %li\n", | 	  fprintf (dump_file, "  upper bound: %li\n", | ||||||
| 		   (long)max_loop_iterations_int (loop)); | 		   (long)get_max_loop_iterations_int (loop)); | ||||||
| 	  fprintf (dump_file, "  realistic bound: %li\n", | 	  fprintf (dump_file, "  realistic bound: %li\n", | ||||||
| 		   (long)estimated_loop_iterations_int (loop)); | 		   (long)get_estimated_loop_iterations_int (loop)); | ||||||
| 	} | 	} | ||||||
|       else |       else | ||||||
| 	fprintf (dump_file, "Loop %d is not simple.\n", loop->num); | 	fprintf (dump_file, "Loop %d is not simple.\n", loop->num); | ||||||
|  |  | ||||||
|  | @ -469,7 +469,7 @@ decide_peel_once_rolling (struct loop *loop, int flags ATTRIBUTE_UNUSED) | ||||||
|       || desc->infinite |       || desc->infinite | ||||||
|       || !desc->const_iter |       || !desc->const_iter | ||||||
|       || (desc->niter != 0 |       || (desc->niter != 0 | ||||||
| 	  && max_loop_iterations_int (loop) != 0)) | 	  && get_max_loop_iterations_int (loop) != 0)) | ||||||
|     { |     { | ||||||
|       if (dump_file) |       if (dump_file) | ||||||
| 	fprintf (dump_file, | 	fprintf (dump_file, | ||||||
|  |  | ||||||
|  | @ -304,7 +304,7 @@ unswitch_single_loop (struct loop *loop, rtx cond_checked, int num) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   /* Nor if the loop usually does not roll.  */ |   /* Nor if the loop usually does not roll.  */ | ||||||
|   iterations = estimated_loop_iterations_int (loop); |   iterations = get_estimated_loop_iterations_int (loop); | ||||||
|   if (iterations >= 0 && iterations <= 1) |   if (iterations >= 0 && iterations <= 1) | ||||||
|     { |     { | ||||||
|       if (dump_file) |       if (dump_file) | ||||||
|  |  | ||||||
|  | @ -3388,6 +3388,27 @@ estimated_loop_iterations (struct loop *loop, double_int *nit) | ||||||
|   return (get_estimated_loop_iterations (loop, nit)); |   return (get_estimated_loop_iterations (loop, nit)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /* Similar to estimated_loop_iterations, but returns the estimate only
 | ||||||
|  |    if it fits to HOST_WIDE_INT.  If this is not the case, or the estimate | ||||||
|  |    on the number of iterations of LOOP could not be derived, returns -1.  */ | ||||||
|  | 
 | ||||||
|  | HOST_WIDE_INT | ||||||
|  | estimated_loop_iterations_int (struct loop *loop) | ||||||
|  | { | ||||||
|  |   double_int nit; | ||||||
|  |   HOST_WIDE_INT hwi_nit; | ||||||
|  | 
 | ||||||
|  |   if (!estimated_loop_iterations (loop, &nit)) | ||||||
|  |     return -1; | ||||||
|  | 
 | ||||||
|  |   if (!nit.fits_shwi ()) | ||||||
|  |     return -1; | ||||||
|  |   hwi_nit = nit.to_shwi (); | ||||||
|  | 
 | ||||||
|  |   return hwi_nit < 0 ? -1 : hwi_nit; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /* Sets NIT to an upper bound for the maximum number of executions of the
 | /* Sets NIT to an upper bound for the maximum number of executions of the
 | ||||||
|    latch of the LOOP.  If we have no reliable estimate, the function returns |    latch of the LOOP.  If we have no reliable estimate, the function returns | ||||||
|    false, otherwise returns true.  */ |    false, otherwise returns true.  */ | ||||||
|  |  | ||||||
|  | @ -30,7 +30,9 @@ extern bool finite_loop_p (struct loop *); | ||||||
| extern tree loop_niter_by_eval (struct loop *, edge); | extern tree loop_niter_by_eval (struct loop *, edge); | ||||||
| extern tree find_loop_niter_by_eval (struct loop *, edge *); | extern tree find_loop_niter_by_eval (struct loop *, edge *); | ||||||
| extern bool estimated_loop_iterations (struct loop *, double_int *); | extern bool estimated_loop_iterations (struct loop *, double_int *); | ||||||
|  | extern HOST_WIDE_INT estimated_loop_iterations_int (struct loop *); | ||||||
| extern bool max_loop_iterations (struct loop *, double_int *); | extern bool max_loop_iterations (struct loop *, double_int *); | ||||||
|  | extern HOST_WIDE_INT max_loop_iterations_int (struct loop *); | ||||||
| extern HOST_WIDE_INT max_stmt_executions_int (struct loop *); | extern HOST_WIDE_INT max_stmt_executions_int (struct loop *); | ||||||
| extern HOST_WIDE_INT estimated_stmt_executions_int (struct loop *); | extern HOST_WIDE_INT estimated_stmt_executions_int (struct loop *); | ||||||
| extern bool max_stmt_executions (struct loop *, double_int *); | extern bool max_stmt_executions (struct loop *, double_int *); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Andrew MacLeod
						Andrew MacLeod