On Tue, Dec 2, 2025 at 11:40 AM Eric Botcazou <[email protected]> wrote:
>
> > The following uses ranger to try to simplify boolean expressions
> > in simplify_using_initial_conditions as used by niter analysis.
> > We also try to simplify niter expressions themselves, but we cannot
> > use ranger directly for this.
> >
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
> >
> >       * tree-ssa-loop-niter.cc (simplify_using_initial_conditions):
> >       Use the active ranger to simplify boolean expressions.
>
> Boolean types can have precision > 1 so using !undefined_p && !varying_p is
> not sufficient for them:
>
> // Types of value ranges.
> enum value_range_kind
> {
>   /* Empty range.  */
>   VR_UNDEFINED,
>   /* Range spans the entire domain.  */
>   VR_VARYING,
>   /* Range is [MIN, MAX].  */
>   VR_RANGE,
>   /* Range is ~[MIN, MAX].  */
>   VR_ANTI_RANGE,
>   /* Range is a NAN.  */
>   VR_NAN,
>   /* Range is a nice guy.  */
>   VR_LAST
> };
>
> Breakpoint 1, simplify_using_initial_conditions (loop=0x7ffff5a09af0,
>     expr=0x7ffff5a69960)
>     at /home/eric/gnat/gnat-head/src/gcc/tree-ssa-loop-niter.cc:3095
> 3095        return expr_range.nonzero_p () ? boolean_true_node :
> boolean_false_node;
> (types__TintB) opt__maximum_file_name_length.26_178 + -2 > flength_272
> (gdb) p debug (expr_range)
> [irange] boolean [0, 1]
> (gdb) call expr_range.varying_p ()
> $95 = false
>
> Tested on x86-64/Linux, OK for the mainline?

OK.

Thanks,
Richard.

>
>         PR tree-optimization/122934
>         * tree-ssa-loop-niter.cc (simplify_using_initial_conditions): Use
>         singleton_p predicate even with boolean ranges.
>
>
> --
> Eric Botcazou

Reply via email to