This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Proper use of x86/x86_64 CPUID instruction with extended assembler




On 08/19/2015 12:56 PM, Jeffrey Walton wrote:
(I also looked at
https://gcc.gnu.org/ml/gcc-patches/2007-09/msg00324.html, which is a
GCC patch for cpuid.h. But its not clear to me if the above is correct
because the operands are 32-bit in size. Naively, if I use "a" and "b"
with a 32-bit operand, then I would expect code for EAX and EBX; and
not RAX and RBX).
It is correct.
Thanks Avi. Regarding the GCC patch... if the output register and the
ABI tells GCC that EBX needs to be preserved, then why does the patch
take special steps to preserve it?


Well I just tried it, and gcc is indeed not clever enough to do this on its
own.  So it is needed.
And one more related question... The Intel folks state to minimize the
use of the the XCHG instruction because it has lock overhead
(https://software.intel.com/en-us/forums/topic/393587). Should the GCC
patch example be using a simple push/pop instead of an XCHG?


reg/reg xchg has no lock overhead.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]