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

--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 10 Nov 2025, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122620
> 
> --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> 2025-11-10  Jakub Jelinek  <[email protected]>
> 
>         PR lto/122620
>         * gimplify-me.cc (gimple_regimplify_operands): Don't try to regimplify
>         TREE_CLOBBER on rhs of gimple_clobber_p if it has gimple_reg_type.
> 
> --- gcc/gimplify-me.cc.jj       2025-10-22 13:30:36.000000000 +0200
> +++ gcc/gimplify-me.cc  2025-11-10 15:32:24.747470202 +0100
> @@ -232,9 +232,13 @@ gimple_regimplify_operands (gimple *stmt
>           else if (i == 2
>                    && gimple_assign_single_p (stmt)
>                    && num_ops == 2)
> -           gimplify_expr (&op, &pre, NULL,
> -                          rhs_predicate_for (gimple_assign_lhs (stmt)),
> -                          fb_rvalue);
> +           {
> +             if (gimple_clobber_p (stmt))
> +               continue;
> +             gimplify_expr (&op, &pre, NULL,
> +                            rhs_predicate_for (gimple_assign_lhs (stmt)),
> +                            fb_rvalue);
> +           }
>           else if (i == 2 && is_gimple_call (stmt))
>             {
>               if (TREE_CODE (op) == FUNCTION_DECL)
> @@ -253,8 +257,9 @@ gimple_regimplify_operands (gimple *stmt
>         {
>           bool need_temp = false;
> 
> -         if (gimple_assign_single_p (stmt)
> -             && num_ops == 2)
> +         if (gimple_clobber_p (stmt))
> +           ;
> +         else if (gimple_assign_single_p (stmt) && num_ops == 2)
>             gimplify_expr (gimple_assign_rhs1_ptr (stmt), &pre, NULL,
>                            rhs_predicate_for (gimple_assign_lhs (stmt)),
>                            fb_rvalue);

LGTM.

> seems to fix the ICE for me, but I haven't been successful in trying to
> minimize a testcase for this.  I can manage to have a MEM_REF = CLOBBER with
> int or other gimple reg type very easily, but haven't managed so far to force
> either OpenMP or inliner (the only spots which regimplify stuff) to trigger
> regimplification of it.

I'd suspect it needs either a DECL_VALUE_EXPR or a DECL_BY_REFERENCE
address which possibly before inlining is invariant &decl but after
inlining it's now &MEM[p+...].  Plus of course somehow a clobber
of it has to appear.  Maybe sth like

S foo ()
{
  S v;
  ~v;
  return v;
}

or sth similarly "bogus".  You could try breaking on the two relevant
id->regimplify = true cases in the inliner around ADDR_EXPRs.

Reply via email to