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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> but lack the same check for the x parts.  The following fixes it:
> 
> diff --git a/gcc/expr.c b/gcc/expr.c
> index b97c217e86d..dfbeae71518 100644
> --- a/gcc/expr.c
> +++ b/gcc/expr.c
> @@ -3692,6 +3692,11 @@ emit_move_multi_word (machine_mode mode, rtx x, rtx y)
>    need_clobber = false;
>    for (i = 0; i < CEIL (mode_size, UNITS_PER_WORD); i++)
>      {
> +      /* Do not generate code for a move if it would go entirely
> +        to the non-existing bits of a paradoxical subreg.  */
> +      if (undefined_operand_subword_p (x, i))
> +       continue;
> +
>        rtx xpart = operand_subword (x, i, 1, mode);
>        rtx ypart;

but only to get to the next one:

during RTL pass: subreg1
pr94574.c: In function ‘foo’:
pr94574.c:15:1: internal compiler error: in simplify_gen_subreg_concatn, at
lower-subreg.c:717
   15 | }
      | ^
0x1f7188d simplify_gen_subreg_concatn
        /space/rguenther/src/gcc/gcc/lower-subreg.c:717
0x1f72a3d resolve_clobber
        /space/rguenther/src/gcc/gcc/lower-subreg.c:1160
0x1f73e5b decompose_multiword_subregs
        /space/rguenther/src/gcc/gcc/lower-subreg.c:1610
0x1f743f5 execute
        /space/rguenther/src/gcc/gcc/lower-subreg.c:1765
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

#1  0x0000000001f7188e in simplify_gen_subreg_concatn (outermode=E_SImode, 
    op=0x7ffff69f66c0, innermode=E_TImode, byte=0)
    at /space/rguenther/src/gcc/gcc/lower-subreg.c:717
717               gcc_assert (!paradoxical_subreg_p (op));

where it tries to fixup

(clobber (subreg:TI (concatn/v:DI [
                (reg:SI 117 [ res ])
                (reg:SI 118 [ res+4 ])
            ]) 0))

but a clobber of a paradoxical subreg is simply the same as a clobber of
the SUBREG_REG (the concat in this case)?  Thus, fixed by

diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c
index a170f0ff93b..a11e535b5bf 100644
--- a/gcc/lower-subreg.c
+++ b/gcc/lower-subreg.c
@@ -1150,6 +1150,10 @@ resolve_clobber (rtx pat, rtx_insn *insn)
   int ret;

   reg = XEXP (pat, 0);
+  /* For clobbers we can look through paradoxical subregs which
+     we do not handle in simplify_gen_subreg_concatn.  */
+  if (paradoxical_subreg_p (reg))
+    reg = SUBREG_REG (reg);
   if (!resolve_reg_p (reg) && !resolve_subreg_p (reg))
     return false;

Reply via email to