This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/50772] Inline assembler "A" constrain works non-expectedly on 64-bits target
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Oct 2011 09:27:34 +0000
- Subject: [Bug inline-asm/50772] Inline assembler "A" constrain works non-expectedly on 64-bits target
- Auto-submitted: auto-generated
- References: <bug-50772-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50772
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-18 09:27:34 UTC ---
Documentation says:
@item A
The @code{a} and @code{d} registers. This class is used for instructions
that return double word results in the @code{ax:dx} register pair. Single
word values will be allocated either in @code{ax} or @code{dx}.
For example on i386 the following implements @code{rdtsc}:
@smallexample
unsigned long long rdtsc (void)
@{
unsigned long long tick;
__asm__ __volatile__("rdtsc":"=A"(tick));
return tick;
@}
@end smallexample
This is not correct on x86_64 as it would allocate tick in either @code{ax}
or @code{dx}. You have to use the following variant instead:
@smallexample
unsigned long long rdtsc (void)
@{
unsigned int tickl, tickh;
__asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh));
return ((unsigned long long)tickh << 32)|tickl;
@}
@end smallexample