On Tue, 18 May 2021, Jakub Jelinek wrote:

> Hi!
> 
> The following testcase ICEs, because copyprop_hardreg_forward_1 decides
> to DCE asm goto with REG_UNUSED notes (because the output is unused and
> asm isn't volatile).  But that DCE just removes the asm goto, leaving
> a bb with two successors and no insn at the end that would allow that.
> 
> The following patch makes sure we drop that way only INSNs and not
> JUMP_INSNs or CALL_INSNs.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

> 2021-05-18  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR rtl-optimization/100590
>       * regcprop.c (copyprop_hardreg_forward_1): Only DCE dead sets if
>       they are NONJUMP_INSN_P.
> 
>       * gcc.dg/pr100590.c: New test.
> 
> --- gcc/regcprop.c.jj 2021-05-15 10:12:04.000000000 +0200
> +++ gcc/regcprop.c    2021-05-17 20:38:26.993109935 +0200
> @@ -808,6 +808,7 @@ copyprop_hardreg_forward_1 (basic_block
>        /* Detect obviously dead sets (via REG_UNUSED notes) and remove them.  
> */
>        if (set
>         && !RTX_FRAME_RELATED_P (insn)
> +       && NONJUMP_INSN_P (insn)
>         && !may_trap_p (set)
>         && find_reg_note (insn, REG_UNUSED, SET_DEST (set))
>         && !side_effects_p (SET_SRC (set))
> --- gcc/testsuite/gcc.dg/pr100590.c.jj        2021-05-17 20:43:37.261699508 
> +0200
> +++ gcc/testsuite/gcc.dg/pr100590.c   2021-05-17 20:43:12.988966308 +0200
> @@ -0,0 +1,13 @@
> +/* PR rtl-optimization/100590 */
> +/* { dg-do compile } */
> +/* { dg-options "-O1 -fno-dce -w" } */
> +
> +int
> +foo (void)
> +{
> +  int x;
> +  asm goto ("" : "+r" (x) : : : lab);
> +  return 0;
> + lab:
> +  return 1;
> +}
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

Reply via email to