[llvm-commits] [PATCH] Correct AVX detection in X86Subtarget::AutoDetectSubtargetFeatures()

Alex Rønne Petersen alex at lycus.org
Mon Aug 27 19:05:55 PDT 2012


OK, I've removed the XSAVE check.

I know that, strictly speaking, checking XGETBV is necessary too, but:

1) I haven't come across any OS that sets OSXSAVE and doesn't enable it;
2) My inline asm-fu with the various supported compilers isn't very strong.

I've added a TODO in the patch, in the hopes that someone who's more
familiar with this stuff than I am might be able to help.

In any case, the patch should fix one particular case of incorrect AVX
detection (LLVM thinking that Windows 7 below SP1 has AVX support, for
instance).

Thanks for the review!

On Sun, Aug 26, 2012 at 6:20 AM, Craig Topper <craig.topper at gmail.com>wrote:

> The check for XSAVE isn't necessary since all processors that support AVX
> support XSAVE. Checking OSXSAVE isn't sufficient you would also need to
> check XGETBV to make sure save/restore of XMM and YMM state is enabled by
> the OS.
>
> ~Craig
>
> On Sat, Aug 25, 2012 at 1:33 AM, Alex Rønne Petersen <alex at lycus.org>wrote:
>
>> Hi LLVMers,
>>
>> The AVX detection code in X86Subtarget::AutoDetectSubtargetFeatures()
>> only checked for the CPUID.{EAX = 1}.ECX.AVX bit previously. This is not
>> enough; the XSAVE and OSXSAVE bits also need to be checked to be sure that
>> the OS is aware of XMM/YMM registers and saves them during context
>> switches. This patch fixes that.
>>
>> The patch was created with git diff - I was told svn should be able to
>> work with that.
>>
>> This is my first patch submission, so if I did something wrong, please
>> bear with me. :)
>>
>> Regards,
>> Alex
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>>
>
>
> --
> ~Craig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120828/d071eee9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avx.patch
Type: application/octet-stream
Size: 897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120828/d071eee9/attachment.obj>


More information about the llvm-commits mailing list