This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Patch: Refactor number_of_iterations_exit



----------------------------------------
> Subject: Re: Patch: Refactor number_of_iterations_exit
> From: richard.guenther@gmail.com
> Date: Thu, 7 May 2015 19:47:37 +0200
> To: hiraditya@msn.com; gcc-patches@gcc.gnu.org
>
> On May 7, 2015 6:27:28 PM GMT+02:00, Aditya K <hiraditya@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?

I don't have any data. I was going through this code and realized that when last_stmt(exit->src)
would fail or when the last_stmt is not a conditional it would be pointless to find if exit->src dominates loop->latch
(which would be true for most simple loops, but then most simple loops would have conditionals as last statements. So I'm not very sure about this.)

-Aditya

>
> Richard.
>
>>
>>Thanks,
>>-Aditya
>>
>>
>>2015-05-07  Aditya Kumar  <hiraditya@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)
>>
>>
>
>
 		 	   		  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]