This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, i386]: Implement -mcmpxchg16b and -msahf options
Michael Meissner wrote:
Please note that there are now two conditions to generate SAHF. First
condition checks the architecture feature flag (PTA_NO_SAHF in
processor_alias_table), the second is X86_TUNE_USE_SAHF. So,
-mtune=generic alone won't generate SAHF, but it will be generated in
case -msahf compile flag is used in addition to -mtune=generic.
Attached patch implements processor specific compile options
-mcmpxchg16b and -msahf that instructs the compiler to generate these
instructions in asm code. The compiler driver is further enhanced to
detect availability of these instructions through cpuid query in order
to set appropriate compiler flags for -march=native compilations.If early Intel 64-bit machines did not have SAHF, then generic should not be
Due to this change, X86_TUNE_USE_SAHF flag can be set also for
m_GENERIC64. sahf generation itself is disabled by default, but can be
enabled by -msahf - either manually or via -arch=native. When enabled,
it should be used as it results in smaller, but equivalently fast code
on all 64bit processors. The same logic applies to m_NOCONA (as reported
by Jan). sahf generation is disabled by default for march=nocona, but if
-march=native detects availability of instruction, it enables it via -msahf.
turning it on, unless we know that none of the machines are in use anymore.
Otherwise you might get random segment faults if you bring up Linux, BSD, or
one of the OSes compiled with GCC using the default -mtune=generic.