[PATCH PR78574]Fix infinite recursion in find_deriving_biv_for_expr

Richard Biener richard.guenther@gmail.com
Wed Nov 30 14:11:00 GMT 2016


On Wed, Nov 30, 2016 at 2:54 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> Loop header PHI defining IV(biv) may not be identified as biv because its increment statement is in (irreducible) inner loop.  Function find_deriving_biv_for_expr doesn't take this into consideration and runs into infinite recursion.  The patch fixes this issue by skipping such loop header PHI.  Bootstrap and test on x86_64 and AArch64, is it OK?

Ok.

Richard.

> BTW, we don't mark such IV as biv because of below code:
>
>       /* If the increment is in the subloop, ignore it.  */
>       incr_bb = gimple_bb (SSA_NAME_DEF_STMT (var));
>       if (incr_bb->loop_father != data->current_loop
>           || (incr_bb->flags & BB_IRREDUCIBLE_LOOP))
>         continue;
>
> I thought twice and this check may be too strict.  Given valid incr_iv returned by simple_iv, we know it behaves just like usual increment IVs.  In other words, though the increment statement is executed multiple times in inner loop, it computes the same result for every iteration.  Anyway this is stage1 work.
>
> Thanks,
> bin
>
> 2016-11-30  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/78574
>         * tree-ssa-loop-ivopts.c (find_deriving_biv_for_expr): Skip loop
>         header PHI that doesn't define biv.
>
> gcc/testsuite/ChangeLog
> 2016-11-30  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/78574
>         * gcc.c-torture/compile/pr78574.c: New test.



More information about the Gcc-patches mailing list