summaryrefslogtreecommitdiffstats
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
authoramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-16 15:48:47 +0000
committeramacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-16 15:48:47 +0000
commit4e948f5a157c7d594cb8de102378d1d39644bf90 (patch)
tree8477f2ad269e9d4ebe53cbc7799f7b5a6c9dc5ca /gcc/tree-ssa-loop-niter.c
parent3308cb8ba51c9e5db7e21179576493e7e38c7939 (diff)
downloadppe42-gcc-4e948f5a157c7d594cb8de102378d1d39644bf90.tar.gz
ppe42-gcc-4e948f5a157c7d594cb8de102378d1d39644bf90.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203709 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 8bcb1c6b26e..113c7d103be 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3388,6 +3388,27 @@ estimated_loop_iterations (struct loop *loop, double_int *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
latch of the LOOP. If we have no reliable estimate, the function returns
false, otherwise returns true. */
OpenPOWER on IntegriCloud