[Bug target/80706] [7/8 Regression] peephole2 uses uninitialized stack variables on i686

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu May 11 07:43:00 GMT 2017


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

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Jakub Jelinek from comment #3)
> So peephole2 does here:
> -	fstpl	24(%esp)
> -	movq	24(%esp), %xmm0
> -	movq	%xmm0, 32(%esp)
> +	fstpl	32(%esp)
>  	movl	$0, 32(%esp)
> That is a nice simplification, but has one extra requirement not checked
> (and hard to check) in the peephole2 patterns - that the memory slot stored
> in the first store is a scratch memory not used afterwards (or overwritten
> first, i.e. dead).  While we have peep2_reg_dead_p predicates, we don't have
> peep2_mem_dead_p and implementing that would be hard, only DSE has
> infrastructure to do that, but dse2 is run before peephole2 pass.
> All we could do is simplify the mem[sp+24]=st; xmm0=[sp+24]; [sp+32]=xmm0;
> into mem[sp+24]=st; mem[sp+32]=st; and let the regstack pass figure out
> something with it - fstl 24(%esp); fstpl 32(%esp) ?).  DSE isn't run
> afterwards, so it would be nice to do that earlier though.

Let's keep the dangling store to a temporary here. We already loaded the value
from the memory, so one extra store won't hurt that much...


More information about the Gcc-bugs mailing list