[PATCH] x86: Only use general-purpose registers during CPUID check

Uros Bizjak ubizjak@gmail.com
Sun Aug 23 08:18:28 GMT 2020

On Sat, Aug 22, 2020 at 9:09 PM H.J. Lu <hjl.tools@gmail.com> wrote:

> > > Compile CPUID check with "-mno-sse -mfpmath=387" to disable SSE, AVX and
> > > AVX512 during CPUID check to avoid vector and mask register operations.
> >
> > -mgeneral-regs-only ?
> >
> Here is a patch to add target("general-regs-only") function
> attribute and use it for CPUID check.   OK for master if there
> are no regressions?

Please test it first, then ask for an approval.

Please submit the general-regs-only part as an independent patch. (I
think this is the option linux should use for compilation).

OTOH, wrapping CPUID check in a target attribute is a bad idea. We
should disable spills to mask registers for generic targets by either
raising costs of moves between general and mask registers and/or (as
suggested earlier) introducing TARGET_SPILL_TO_MASK_REGS tuning and
use it in secondary_memory_needed to prevent inter register unit

So, compiling with -mavx512bw would NOT enable spills by default,
where compiling with -march=skylake-avx512 (or using equivalent
-mtune) would. This is IMO the least surprising approach, and would
avoid changing sources (as you now have to do for several testcases).


More information about the Gcc-patches mailing list