Also shouldn't this<div><br></div><div><span class="pygments-kt" style="color:rgb(176,0,64);font-family:monospace;font-size:medium;white-space:pre">bool</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-n" style="font-family:monospace;font-size:medium;white-space:pre">HasAVX</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">=</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">(</span><span class="pygments-n" style="font-family:monospace;font-size:medium;white-space:pre">ECX</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">&</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">((</span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">1</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre"><<</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">28</span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">)</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">|</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">(</span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">1</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre"><<</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">27</span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">)))</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">!=</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">0</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">&&</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-n" style="font-family:monospace;font-size:medium;white-space:pre">OSHasAVXSupport</span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">();</span></div>
<div><font face="monospace" size="3"><span style="white-space:pre"><br></span></font></div><div><font face="monospace" size="3"><span style="white-space:pre">be</span></font></div><div><font face="monospace" size="3"><span style="white-space:pre"><br>
</span></font></div><div><span class="pygments-kt" style="color:rgb(176,0,64);font-family:monospace;font-size:medium;white-space:pre">bool</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-n" style="font-family:monospace;font-size:medium;white-space:pre">HasAVX</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">=</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">(</span><span class="pygments-n" style="font-family:monospace;font-size:medium;white-space:pre">ECX</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">&</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">((</span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">1</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre"><<</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">28</span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">)</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">|</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">(</span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">1</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre"><<</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-mi" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">27</span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">)))</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> <font color="#666666">== ((1 << 28) | (1 << 27))</font></span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-o" style="color:rgb(102,102,102);font-family:monospace;font-size:medium;white-space:pre">&&</span><span style="font-family:monospace;font-size:medium;white-space:pre;background-color:rgb(255,255,255)"> </span><span class="pygments-n" style="font-family:monospace;font-size:medium;white-space:pre">OSHasAVXSupport</span><span class="pygments-p" style="font-family:monospace;font-size:medium;white-space:pre">();</span></div>
<div><font face="monospace" size="3"><span style="white-space:pre"><br></span></font></div><div><font face="monospace" size="3"><span style="white-space:pre">Or variation so that it really checks that both bits are set not that some combination of the two bits is set.</span></font></div>
<div><font face="monospace" size="3"><span style="white-space:pre"><br></span></font></div><div><br><div class="gmail_quote">On Wed, Apr 3, 2013 at 9:23 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The documentation was unclear on this, but I think you're right that<br>
it's only in SP1.  I'll update the code to reflect that, good catch!<br>
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Apr 3, 2013 at 12:14 PM, Craig Topper <<a href="mailto:craig.topper@gmail.com">craig.topper@gmail.com</a>> wrote:<br>
> Isn't _xgetbv only supported by MSVC 2010 SP1? Shouldn't this be checking<br>
> that you're using at least that MSVC version?<br>
><br>
><br>
> On Wed, Apr 3, 2013 at 5:25 AM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> wrote:<br>
>><br>
>> Author: aaronballman<br>
>> Date: Wed Apr  3 07:25:06 2013<br>
>> New Revision: 178636<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=178636&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=178636&view=rev</a><br>
>> Log:<br>
>> Second pass at addressing PR15351 by explicitly checking for AVX support<br>
>> when getting the host processor information.  It emits a .byte sequence on<br>
>> GNUC compilers to work around lack of xgetbv support with older assemblers,<br>
>> and resolves a comment typo found in the previous patch.<br>
>><br>
>> Modified:<br>
>>     llvm/trunk/lib/Support/Host.cpp<br>
>><br>
>> Modified: llvm/trunk/lib/Support/Host.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=178636&r1=178635&r2=178636&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=178636&r1=178635&r2=178636&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Support/Host.cpp (original)<br>
>> +++ llvm/trunk/lib/Support/Host.cpp Wed Apr  3 07:25:06 2013<br>
>> @@ -112,6 +112,21 @@ static bool GetX86CpuIDAndInfo(unsigned<br>
>>  #endif<br>
>>  }<br>
>><br>
>> +static bool OSHasAVXSupport() {<br>
>> +#if defined( __GNUC__ )<br>
>> +  // Check xgetbv; this uses a .byte sequence instead of the instruction<br>
>> +  // directly because older assemblers do not include support for xgetbv<br>
>> and<br>
>> +  // there is no easy way to conditionally compile based on the assembler<br>
>> used.<br>
>> +  int rEAX, rEDX;<br>
>> +  __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a" (rEAX), "=d" (rEDX) : "c"<br>
>> (0));<br>
>> +#elif defined(_MSC_VER)<br>
>> +  unsigned long long rEAX = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);<br>
>> +#else<br>
>> +  int rEAX = 0; // Ensures we return false<br>
>> +#endif<br>
>> +  return (rEAX & 6) == 6;<br>
>> +}<br>
>> +<br>
>>  static void DetectX86FamilyModel(unsigned EAX, unsigned &Family,<br>
>>                                   unsigned &Model) {<br>
>>    Family = (EAX >> 8) & 0xf; // Bits 8 - 11<br>
>> @@ -134,6 +149,10 @@ std::string sys::getHostCPUName() {<br>
>>    DetectX86FamilyModel(EAX, Family, Model);<br>
>><br>
>>    bool HasSSE3 = (ECX & 0x1);<br>
>> +  // If CPUID indicates support for XSAVE, XRESTORE and AVX, and XGETBV<br>
>> +  // indicates that the AVX registers will be saved and restored on<br>
>> context<br>
>> +  // switch, then we have full AVX support.<br>
>> +  bool HasAVX = (ECX & ((1 << 28) | (1 << 27))) != 0 &&<br>
>> OSHasAVXSupport();<br>
>>    GetX86CpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);<br>
>>    bool Em64T = (EDX >> 29) & 0x1;<br>
>><br>
>> @@ -243,11 +262,15 @@ std::string sys::getHostCPUName() {<br>
>>        case 42: // Intel Core i7 processor. All processors are<br>
>> manufactured<br>
>>                 // using the 32 nm process.<br>
>>        case 45:<br>
>> -        return "corei7-avx";<br>
>> +        // Not all Sandy Bridge processors support AVX (such as the<br>
>> Pentium<br>
>> +        // versions instead of the i7 versions).<br>
>> +        return HasAVX ? "corei7-avx" : "corei7";<br>
>><br>
>>        // Ivy Bridge:<br>
>>        case 58:<br>
>> -        return "core-avx-i";<br>
>> +        // Not all Ivy Bridge processors support AVX (such as the Pentium<br>
>> +        // versions instead of the i7 versions).<br>
>> +        return HasAVX ? "core-avx-i" : "corei7";<br>
>><br>
>>        case 28: // Most 45 nm Intel Atom processors<br>
>>        case 38: // 45 nm Atom Lincroft<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
><br>
> --<br>
> ~Craig<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>~Craig
</div>