[cfe-commits] [PATCH] Clean up and fix X86 features
Eli Friedman
eli.friedman at gmail.com
Fri Nov 16 17:44:40 PST 2012
r168237+r168239.
-Eli
On Thu, Nov 15, 2012 at 4:28 PM, Jung-uk Kim <jkim at freebsd.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2012-11-15 18:47:04 -0500, Jung-uk Kim wrote:
>> On 2012-11-15 16:52:49 -0500, Eli Friedman wrote:
>>> On Thu, Nov 15, 2012 at 10:41 AM, Jung-uk Kim <jkim at freebsd.org>
>>> wrote:
>>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>>>>
>>>> [This is actually PR14344 but I was told to submit the patch
>>>> here. Please see the PR14344 for the PR history.]
>>>>
>>>> I have an AMD Family 10h processor and I realized that LZCNT
>>>> and POPCNT are not enabled by default. Then, I looked at
>>>> lib/Basic/Targets.cpp and found it needs some love (e.g.,
>>>> sync. with LLVM's X86.td). :-)
>>>>
>>>> Please see the attached patch.
>>>>
>>>> - - AMD Barcelona("amdfam10") and later processors have LZCNT
>>>> and POPCNT instructions. - - AMD Piledriver("bdver2") and
>>>> later processors have BMI, FMA, and F16C instructions. - -
>>>> Intel Ivy Bridge("core-avx-i") and later processors have F16C
>>>> instructions. - - Do not set SIMD sets (i.e., MMX, SSE3, and
>>>> AVX) when they are implicitly set via higher instruction sets.
>>>> - - Do not enable POPCNT instruction with SSE4* instruction
>>>> sets as they are not part of the specifications nor uses SIMD
>>>> registers. [1]
>>>>
>>>> Jung-uk Kim
>>>>
>>>> [1] It has little bit of history behind it. AMD called them
>>>> ABM and they added "-mabm" option to GCC, which enabled both
>>>> LZCNT and POPCNT instructions. OTOH, Intel implemented POPCNT
>>>> first (Arrandale), then LZCNT later (upcoming Haswell).
>>>> Therefore, GCC had to separate the flag and added "-mpopcnt"
>>>> and "-mlzcnt" (but kept "-mabm" for backward compatibility).
>>
>>> Tests are important here; please include the relevant changes for
>>> clang/test/Preprocessor/predefined-arch-macros.c .
>>
>> Attached (not tried yet). Please note I had to add missing tests
>> for AMD processors.
>
> The attached patch restores a bug-for-bug compatibility with GCC,
> i.e., SSE4/SSE4.2/AVX/FMA/FMA4/XOP enables POPCNT. Although I am not
> really in favor of this, it may be important for some people.
>
> Jung-uk Kim
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.19 (FreeBSD)
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iEYEARECAAYFAlCliK0ACgkQmlay1b9qnVNBHgCgwhA7Lv7AyY2YjStwC/9qjOh7
> mxAAnjjaWyQFCwLncqDF0fu3r4POQA2M
> =z7ng
> -----END PGP SIGNATURE-----
More information about the cfe-commits
mailing list