diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2013-10-16 15:48:47 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 2013-10-16 15:48:47 +0000 |
commit | 1ef88893457d51ad3429eab97fb6edd56c9db646 (patch) | |
tree | 8477f2ad269e9d4ebe53cbc7799f7b5a6c9dc5ca /gcc/cfgloop.c | |
parent | c22df64f91c2f4fcd22eb94ed55af08095e3ad78 (diff) | |
download | gcc-1ef88893457d51ad3429eab97fb6edd56c9db646.zip gcc-1ef88893457d51ad3429eab97fb6edd56c9db646.tar.gz gcc-1ef88893457d51ad3429eab97fb6edd56c9db646.tar.bz2 |
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
Diffstat (limited to 'gcc/cfgloop.c')
-rw-r--r-- | gcc/cfgloop.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index 272a675..28e30ea 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -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; } -/* 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 on the number of iterations of LOOP could not be derived, returns -1. */ HOST_WIDE_INT -estimated_loop_iterations_int (struct loop *loop) +get_estimated_loop_iterations_int (struct loop *loop) { double_int nit; HOST_WIDE_INT hwi_nit; @@ -1842,7 +1842,7 @@ estimated_loop_iterations_int (struct loop *loop) HOST_WIDE_INT 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; if (nit == -1) @@ -1891,3 +1891,25 @@ get_max_loop_iterations (struct loop *loop, double_int *nit) *nit = loop->nb_iterations_upper_bound; 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; +} + + |