On May 7, 2015 6:27:28 PM GMT+02:00, Aditya K <hiradi...@msn.com> wrote: >Hi, >I refactored number_of_iterations_exit a little bit. I hope it is >helpful. >The idea is to move the call to function dominated_by_p after some >sanity checks so as to avoid call to it.
The call is very cheap though. Do you have data that shows it often passes when the later checks fail? Richard. > >Thanks, >-Aditya > > >2015-05-07 Aditya Kumar <hiradi...@msn.com> > > * tree-ssa-loop-niter.c (number_of_iterations_exit): Move call >to dominated_by_p later in the function. > >diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c >index 042f8df..3d49bb8 100644 >--- a/gcc/tree-ssa-loop-niter.c >+++ b/gcc/tree-ssa-loop-niter.c >@@ -1959,11 +1959,6 @@ number_of_iterations_exit (struct loop *loop, >edge exit, > affine_iv iv0, iv1; > bool safe; > >- safe = dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src); >- >- if (every_iteration && !safe) >- return false; >- > niter->assumptions = boolean_false_node; > last = last_stmt (exit->src); > if (!last) >@@ -1972,6 +1967,11 @@ number_of_iterations_exit (struct loop *loop, >edge exit, > if (!stmt) > return false; > >+ safe = dominated_by_p (CDI_DOMINATORS, loop->latch, exit->src); >+ >+ if (every_iteration && !safe) >+ return false; >+ > /* We want the condition for staying inside loop. */ > code = gimple_cond_code (stmt); > if (exit->flags & EDGE_TRUE_VALUE) > >