https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69891
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #3)
> The problematic store is based on argp so it isn't killed by the memset,
> since only those based on sp or fp are:
>
> **scanning insn=20
> mem: (symbol_ref:SI ("memset") [flags 0x41] <function_decl 0x7ffff6d1ee00
> memset>)
>
> after canon_rtx address: (symbol_ref:SI ("memset") [flags 0x41]
> <function_decl 0x7ffff6d1ee00 memset>)
> gid=1 offset=0
> processing const load gid=1[0..1)
> removing from active insn=19 has store
> removing from active insn=18 has store
> removing from active insn=17 has store
> memset call 20
>
> It's apparently a small loophole in the PR middle-end/31150 enhancement.
>
> Index: dse.c
> ===================================================================
> --- dse.c (revision 233545)
> +++ dse.c (working copy)
> @@ -2528,6 +2528,10 @@ scan_insn (bb_info_t bb_info, rtx_insn *
> i_ptr = i_ptr->next_local_store;
> }
>
> + /* But a call to memset clobbers memory so invalidates stores.
> It's
> + not only an optimization issue (the previous stores may be dead)
> + but also a correctness issue since the previous stores cannot be
> + seen as the source of the current value of the locations. */
> if (memset_call)
> {
> rtx args[3];
> @@ -2556,6 +2560,8 @@ scan_insn (bb_info_t bb_info, rtx_insn *
> active_local_stores = insn_info;
> }
> }
> + else
> + add_non_frame_wild_read (bb_info);
> }
> }
> else if (SIBLING_CALL_P (insn) && reload_completed)
>
>
> Jakub, does this look good to you?
But the memset could be also SIBLING_CALL_P.
Wouldn't it be better to change the else if to if, and add
if (const_call) return;
plus return to the end of mems_found == 1 then block? Then it would fall
through to arbitrary other call handling.