[PATCH 2/7] Duplicate the range information of the phi onto the new ssa_name

Richard Biener richard.guenther@gmail.com
Mon Jun 21 06:49:33 GMT 2021


On Sat, Jun 19, 2021 at 9:49 PM apinski--- via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Andrew Pinski <apinski@marvell.com>
>
> Since match_simplify_replacement uses gimple_simplify, there is a new
> ssa name created sometimes and then we go and replace the phi edge with
> this new ssa name, the range information on the phi is lost.
> I don't have a testcase right now where we lose the range information
> though but it does show up when enhancing match.pd to handle
> some min/max patterns and g++.dg/warn/Wstringop-overflow-1.C starts
> to fail.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
>
> gcc/ChangeLog:
>
>         * tree-ssa-phiopt.c (match_simplify_replacement): Duplicate range
>         info if we're the only things setting the target PHI.
> ---
>  gcc/tree-ssa-phiopt.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
> index 24cbce9955a..feb8ca8d0d1 100644
> --- a/gcc/tree-ssa-phiopt.c
> +++ b/gcc/tree-ssa-phiopt.c
> @@ -894,6 +894,14 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
>        gsi_move_before (&gsi1, &gsi);
>        reset_flow_sensitive_info (gimple_assign_lhs (stmt_to_move));
>      }
> +  /* Duplicate range info if we're the only things setting the target PHI.  */
> +  tree phi_result = PHI_RESULT (phi);
> +  if (!gimple_seq_empty_p (seq)
> +      && EDGE_COUNT (gimple_bb (phi)->preds) == 2
> +      && !POINTER_TYPE_P (TREE_TYPE (phi_result))

Please use INTEGRAL_TYPE_P (...)

> +      && SSA_NAME_RANGE_INFO (phi_result)

&& !SSA_NAME_RANGE_INFO (result)

?  Why conditional on !gimple_seq_empty_p (seq)?

It looks like we could do this trick (actually in both directions,
wherever the range
info is missing?) in replace_phi_edge_with_variable instead?

Thanks,
Richard.

)
> +    duplicate_ssa_name_range_info (result, SSA_NAME_RANGE_TYPE (phi_result),
> +                                  SSA_NAME_RANGE_INFO (phi_result));
>    if (seq)
>      gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
>
> --
> 2.27.0
>


More information about the Gcc-patches mailing list