Richard,

Here is updated patch which includes (1) a test on exit proposed by
you and (2) another test from PR68021 which is caught by new check on
counted loop. Outer-loop unswitching is not performed for both new
tests.

Bootstrapping and regression testing did not show any new failures.

Is it OK for trunk.

ChangeLog:
2014-12-16  Yuri Rumyantsev  <ysrum...@gmail.com>

PR tree-optimization/68021
PR tree-optimization/68906
* tree-ssa-loop-unswitch.c : Include couple header files.
(tree_unswitch_outer_loop): Add check that an exit is not inside inner
loop, use number_of_latch_executions to detect non-iterated loops.

gcc/testsuite/ChangeLog
* gcc.dg/torture/pr68021.c: New test.
* gcc.dg/torture/pr68906.c: Likewise.

2015-12-16 15:51 GMT+03:00 Richard Biener <richard.guent...@gmail.com>:
> On Wed, Dec 16, 2015 at 1:14 PM, Yuri Rumyantsev <ysrum...@gmail.com> wrote:
>> Hi All,
>>
>> Here is simple patch which cures the issue with outer-loop unswitching
>> - added invocation of number_of_latch_executions() to reject
>> unswitching for non-iterated loops.
>>
>> Bootstrapping and regression testing did not show any new failures.
>> Is it OK for trunk?
>
> No, that looks like just papering over the issue.
>
> The issue (with the 2nd testcase at least) is that single_exit () accepts
> an exit from the inner loop.
>
> Index: gcc/tree-ssa-loop-unswitch.c
> ===================================================================
> --- gcc/tree-ssa-loop-unswitch.c        (revision 231686)
> +++ gcc/tree-ssa-loop-unswitch.c        (working copy)
> @@ -431,7 +431,7 @@ tree_unswitch_outer_loop (struct loop *l
>      return false;
>    /* Accept loops with single exit only.  */
>    exit = single_exit (loop);
> -  if (!exit)
> +  if (!exit || exit->src->loop_father != loop)
>      return false;
>    /* Check that phi argument of exit edge is not defined inside loop.  */
>    if (!check_exit_phi (loop))
>
> fixes the runtime testcase for me (not suitable for the testsuite due
> to the infinite
> looping though).
>
> Can you please bootstrap/test the above with your testcase?  The above patch 
> is
> ok if it passes testing (no time myself right now)
>
> Thanks,
> Richard.
>
>> ChangeLog:
>>
>> 2014-12-16  Yuri Rumyantsev  <ysrum...@gmail.com>
>>
>> PR tree-optimization/68906
>> * tree-ssa-loop-unswitch.c : Include couple header files.
>> (tree_unswitch_outer_loop): Use number_of_latch_executions
>> to reject non-iterated loops.
>>
>> gcc/testsuite/ChangeLog
>> * gcc.dg/torture/pr68906.c: New test.

Attachment: patch.1
Description: Binary data

Reply via email to