This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: i386 inline-asm string functions - some questions
- From: Roland McGrath <roland at redhat dot com>
- To: Denis Zaitsev <zzz at anda dot ru>
- Cc: Andreas Jaeger <aj at suse dot de>, Richard Henderson <rth at redhat dot com>,libc-alpha at sources dot redhat dot com, linux-gcc at vger dot kernel dot org,gcc at gcc dot gnu dot org
- Date: Wed, 24 Dec 2003 16:39:37 -0800
- Subject: Re: i386 inline-asm string functions - some questions
> >From some moment in the past, the next input parameters are used here
> and there in sysdeps/i386/i486/bits/string.h:
>
> "m" ( *(struct { char __x[0xfffffff]; } *)__s)
>
> When I was seeking for the reasons to do so, I've found some
> discussions about this in libc-alpha and gcc mailing lists. As I
> understand from there, there are an options - to use the "m" arg(s)
> shown above or just to use "memory" in the list of a clobbered
> registers. So, the question is: why the "m"-way had been choosen?
The reason we use this kind of "m" constraint is that it indicates what we
want to say: memory __s points to might be used. That means that if the C
aliasing rules allow the compiler to assume that a given other expression
cannot point to the same memory as __s does, it is free to do so and
optimize out stores through unrelated pointers that cannot affect __s.
Conversely, a "memory" clobber tells the compiler that it must assume that
all memory any pointer points to might be read by this asm.
> I'm asking, because I've found that this "m"-way leads GCC to produce
> an unoptimal enough assembler, while "memory" code is ok.
That is an issue for GCC. It is correct for glibc (and other code) to use
the asm constraints that express the true precise set of constraints and
tell the compiler it is free to do us much as is in fact safe. As to
whether your "+&r" constraints on the pointer values are correct, I don't know.