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

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #9)
> --- gimple-ssa-evrp-analyze.c (revision 268474)
> +++ gimple-ssa-evrp-analyze.c (working copy)
> @@ -217,7 +217,8 @@ evrp_range_analyzer::record_ranges_from_
>             push_value_range (vrs[i].first, vrs[i].second);
>             if (is_fallthru
>                 && m_update_global_ranges
> -               && all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt))
> +               && all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt)
> +               && !has_single_use (vrs[i].first))
>               {
>                 set_ssa_range_info (vrs[i].first, vrs[i].second);
>                 maybe_set_nonzero_bits (pred_e, vrs[i].first);
> 
> does remove the warning on the reduced testcase. But I didn't run the
> testsuite to check if it made sense. And if it does, it should probably come
> before all_uses_feed_or_dominated_by_stmt because it is cheaper (or be
> integrated with it, since it also iterates over all uses and is used only
> here).

I think there are cases where we set useful range even on other SSA_NAMEs than
the single one used in the condition, and in some cases it should be good
enough, even when the SSA_NAME from the condition has single use.
Canonical example would be if (int_arg + 32U <= 64U) __builtin_unreachable (),
etc.  So I wonder if we don't need to differentiate between that and the case
like here, where we really don't derive anything useful from it something &
const == const2, and if the other SSA_NAME(s) got useful range and any of them
isn't single use, remove it too.

Reply via email to