[Bug target/85100] __builtin_cpu_supports avx does not verify OS supports it

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Mar 29 06:32:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85100

--- Comment #8 from Uroš Bizjak <ubizjak at gmail dot com> ---
Comment on attachment 43793
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43793
A patch

>+  if ((ecx & bit_OSXSAVE))
>+    {
>+      /* Check if XMM state and YMM state are saved.  */
>+      unsigned int xcrlow;
>+      unsigned int xcrhigh;
>+      asm ("xgetbv" : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0));
>+      if ((xcrlow & 0x6) == 0x6)

Please use .byte stream instead of xgetbv mnemonic (libgcc can be compiled with
an assembler that doesn't support xgetbv. Actually, you can just copy the part
from driver-i386.c, preferrably also with #defines instead of magic numbers.


More information about the Gcc-bugs mailing list