This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Asm memory constraints
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Alan Modra <amodra at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 20 Aug 2017 08:00:53 -0500
- Subject: Re: [PATCH] Asm memory constraints
- Authentication-results: sourceware.org; auth=none
- References: <20170818144935.GA3368@bubble.grove.modra.org>
Hi Alan,
On Sat, Aug 19, 2017 at 12:19:35AM +0930, Alan Modra wrote:
> +Flushing registers to memory has performance implications and may be
> +an issue for time-sensitive code. You can provide better information
> +to GCC to avoid this, as shown in the following examples. At a
> +minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
> +need to be flushed. Also, if GCC can prove that all of the outputs of
> +a non-volatile @code{asm} statement are unused, then the @code{asm}
> +may be deleted. Removal of otherwise dead @code{asm} statements will
> +not happen if they clobber @code{"memory"}.
void f(int x) { int z; asm("hcf %0,%1" : "=r"(z) : "r"(x) : "memory"); }
void g(int x) { int z; asm("hcf %0,%1" : "=r"(z) : "r"(x)); }
Both f and g are completely removed by the first jump pass immediately
after expand (via delete_trivially_dead_insns).
Do you have a testcase for the behaviour you saw?
Segher