https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109564

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #8)
> I fear something more fundamental is broken here and we
> possibly should play safe and not register any equivalence relation
> from PHIs.
> 
> diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
> index 429734f954a..0c4ffbf3b57 100644
> --- a/gcc/gimple-range-fold.cc
> +++ b/gcc/gimple-range-fold.cc
> @@ -743,6 +744,7 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi,
> fur_source &src)
>    // Track if all executable arguments are the same.
>    tree single_arg = NULL_TREE;
>    bool seen_arg = false;
> +  bool seen_undefined = false;
>  
>    // Start with an empty range, unioning in each argument's range.
>    r.set_undefined ();
> @@ -781,6 +783,8 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi,
> fur_source &src)
>           else if (single_arg != arg)
>             single_arg = NULL_TREE;
>         }
> +      else
> +       seen_undefined = true;
>  
>        // Once the value reaches varying, stop looking.
>        if (r.varying_p () && single_arg == NULL_TREE)
> @@ -802,7 +806,8 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi,
> fur_source &src)
>             // dominate any incoming edge for SINGLE_ARG.
>             // See PR 108139 and 109462.
>             basic_block bb = gimple_bb (phi);
> -           if (!dom_info_available_p (CDI_DOMINATORS))
> +           if (seen_undefined
> +               || !dom_info_available_p (CDI_DOMINATORS))
>               single_arg = NULL;
>             else
>               for (x = 0; x < gimple_phi_num_args (phi); x++)

So on a second thought since with the above we only register equality
for PHIs with all arguments comparing pointer equal that case should be
OK in _all_ cases (including the backedge one).  But it's of course
very rare in the end.

It's btw similar for not executable edges in case arg_range gets undefined_p
in that case.  So I don't think we can allow that case either.

Reply via email to