On Sun, Nov 11, 2018 at 9:02 AM bin.cheng <bin.ch...@linux.alibaba.com> wrote:
>
> Hi,
> This patch fixes PR84648 by adjusting exit conditions for loop-until-wrap 
> cases.
> It only handles simple cases in which IV.base are constants because we rely on
> current niter analyzer which doesn't handle parameterized bound in wrapped
> case.  It could be relaxed in the future.
>
> Bootstrap and test on x86_64 in progress.

Please use TYPE_MIN/MAX_VALUE or wi::min/max_value consistently.
Either tree_int_cst_equal (iv0->base, TYPE_MIN_VALUE (type)) or
wide_int_to_tree (niter_type, wi::max_value (TYPE_PRECISION (type),
TYPE_SIGN (type))).

Also

+  iv0->base = low;
+  iv0->step = fold_convert (niter_type, integer_one_node);

build_int_cst (niter_type, 1);

+  iv1->base = high;
+  iv1->step = integer_zero_node;

build_int_cst (niter_type, 0);

With the code, what happens to signed IVs?  I suppose we figure out things
earlier by means of undefined overflow?

Apart from the above nits OK for trunk.

Thanks,
Richard.

> Thanks,
> bin
> 2018-11-11  Bin Cheng  <bin.ch...@linux.alibaba.com>
>
>         PR tree-optimization/84648
>         * tree-ssa-loop-niter.c (adjust_cond_for_loop_until_wrap): New.
>         (number_of_iterations_cond): Adjust exit cond for loop-until-wrap case
>         by calling adjust_cond_for_loop_until_wrap.
>
> 2018-11-11  Bin Cheng  <bin.ch...@linux.alibaba.com>
>
>         PR tree-optimization/84648
>         * gcc.dg/tree-ssa/pr84648.c: New test.

Reply via email to