[llvm] r178598 - This patch addresses PR15351 by explicitly checking for AVX support

Aaron Ballman aaron at aaronballman.com
Wed Apr 3 05:26:34 PDT 2013


Fixed up the typo in r178636.  Thanks!

~Aaron

On Wed, Apr 3, 2013 at 5:32 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Aaron,
>
>
> On 03/04/13 02:33, Aaron Ballman wrote:
>>
>> Author: aaronballman
>> Date: Tue Apr  2 19:33:32 2013
>> New Revision: 178598
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=178598&view=rev
>> Log:
>> This patch addresses PR15351 by explicitly checking for AVX support
>> when getting the host processor information.
>>
>> Modified:
>>      llvm/trunk/lib/Support/Host.cpp
>>
>> Modified: llvm/trunk/lib/Support/Host.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=178598&r1=178597&r2=178598&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Support/Host.cpp (original)
>> +++ llvm/trunk/lib/Support/Host.cpp Tue Apr  2 19:33:32 2013
>> @@ -112,6 +112,18 @@ static bool GetX86CpuIDAndInfo(unsigned
>>   #endif
>>   }
>>
>> +static bool OSHasAVXSupport() {
>> +#if defined(__GNUC__)
>> +  int rEAX, rEDX;
>> +  __asm__ ("xgetbv" : "=a" (rEAX), "=d" (rEDX) : "c" (0));
>> +#elif defined(_MSC_VER)
>> +  unsigned long long rEAX = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
>> +#else
>> +  int rEAX = 0; // Ensures we return false
>> +#endif
>> +  return (rEAX & 6) == 6;
>> +}
>> +
>>   static void DetectX86FamilyModel(unsigned EAX, unsigned &Family,
>>                                    unsigned &Model) {
>>     Family = (EAX >> 8) & 0xf; // Bits 8 - 11
>> @@ -134,6 +146,10 @@ std::string sys::getHostCPUName() {
>>     DetectX86FamilyModel(EAX, Family, Model);
>>
>>     bool HasSSE3 = (ECX & 0x1);
>> +  // If CPUID indicates support for XSAVE, XRESTORE and AVX, and XGETBV
>> +  // indicates that the AVX registers will be saved and restored on
>> context
>> +  // switch, when we have full AVX support.
>
>
> when we have -> then we have
>
> Ciao, Duncan.
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list