On Sat, Jun 19, 2021 at 11:43 PM apinski--- via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Andrew Pinski <apin...@marvell.com>
>
> While converting some fold_cond_expr_with_comparison
> to match, I found that I wanted to use "for cnd (cond vec_cond)"
> but that was not causing the lowering of cond to happen.
> What was happening was the lowering of the for loop
> was happening after the lowering of the cond. So
> swapping was the correct thing to do but it also
> means we need to copy for_subst_vec in lower_cond.
>
> OK?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.

OK.  Can you please put a comment before for lowering that says
why it's performed before cond lowering and also why it is safe
(for substitution delay does not happen for cond/vec_cond).

Thanks,
Richard.

> gcc/ChangeLog:
>
>         * genmatch.c (lower_cond): Copy for_subst_vec
>         for the simplify also.
>         (lower): Swap the order for lower_for and lower_cond.
> ---
>  gcc/genmatch.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/gcc/genmatch.c b/gcc/genmatch.c
> index 4d47672..3aee3dd 100644
> --- a/gcc/genmatch.c
> +++ b/gcc/genmatch.c
> @@ -1306,6 +1306,7 @@ lower_cond (simplify *s, vec<simplify *>& simplifiers)
>      {
>        simplify *ns = new simplify (s->kind, s->id, matchers[i], s->result,
>                                    s->for_vec, s->capture_ids);
> +      ns->for_subst_vec.safe_splice (s->for_subst_vec);
>        simplifiers.safe_push (ns);
>      }
>  }
> @@ -1543,24 +1544,23 @@ static void
>  lower (vec<simplify *>& simplifiers, bool gimple)
>  {
>    auto_vec<simplify *> out_simplifiers;
> -  for (unsigned i = 0; i < simplifiers.length (); ++i)
> -    lower_opt (simplifiers[i], out_simplifiers);
> +  for (auto s: simplifiers)
> +    lower_opt (s, out_simplifiers);
>
>    simplifiers.truncate (0);
> -  for (unsigned i = 0; i < out_simplifiers.length (); ++i)
> -    lower_commutative (out_simplifiers[i], simplifiers);
> +  for (auto s: out_simplifiers)
> +    lower_commutative (s, simplifiers);
>
>    out_simplifiers.truncate (0);
> -  if (gimple)
> -    for (unsigned i = 0; i < simplifiers.length (); ++i)
> -      lower_cond (simplifiers[i], out_simplifiers);
> -  else
> -    out_simplifiers.safe_splice (simplifiers);
> -
> +  for (auto s: simplifiers)
> +    lower_for (s, out_simplifiers);
>
>    simplifiers.truncate (0);
> -  for (unsigned i = 0; i < out_simplifiers.length (); ++i)
> -    lower_for (out_simplifiers[i], simplifiers);
> +  if (gimple)
> +    for (auto s: out_simplifiers)
> +      lower_cond (s, simplifiers);
> +  else
> +    simplifiers.safe_splice (out_simplifiers);
>  }
>
>
> --
> 1.8.3.1
>

Reply via email to