Tremont microarchitecture only has GFNI(SSE) version, not AVX and
AVX512 version. This patch is to avoid compiling fail on Windows when
using -march=tremont to invoke one of GFNI(SSE) intrinsic.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Headers/gfniintrin.h | ||
---|---|---|
35 | This needs to be more like #if !(defined(_MSC_VER) || defined(SCE)) || __has_feature(modules) || \ (defined(__AVXVL__) && define(__AVX512BW__)) We want all intrinsics to be defined for when not compiling for MSVC compatibility. Otherwise using attribute(target) doesn't work. |
What compilation failure do you get without this? The feature checks are compile time optimization for MSVC because windows.h includes intrin.h.
The fails are all unknown type errors on Windows, since those typedefs are declared in other header files.
The error message goes like:
$ clang -march=tremont gfni.c ...... ...\lib\clang\12.0.0\include\gfniintrin.h:129:37: error: unknown type name '__mmask16' _mm_mask_gf2p8mul_epi8(__m128i __S, __mmask16 __U, __m128i __A, __m128i __B) ^ ...\lib\clang\12.0.0\include\gfniintrin.h:137:25: error: unknown type name '__mmask16' _mm_maskz_gf2p8mul_epi8(__mmask16 __U, __m128i __A, __m128i __B) ^ ...... ...\lib\clang\12.0.0\include\gfniintrin.h:159:43: error: unknown type name '__m256i' _mm256_maskz_gf2p8mul_epi8(__mmask32 __U, __m256i __A, __m256i __B) ^ ... fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.
Ok that makes sense. Maybe the easiest fix is just check that AVXINTRIN_H or AVX512BWINTRIN_H or __AVX512BWVLINTRIN_H is defined where there's a dependency.
Craig's method sounds good.
@FreddyYe , Why we check AVX512BW instead of AVX512F. I saw SDM says it depends on AVX512F.
I think it may result in potential problem once we change the order of them in immintrin.h, it should be better to use the first method.
#if !(defined(_MSC_VER) || defined(SCE)) || __has_feature(modules) || \ (defined(__AVX512VL__) && define(__AVX512BW__))
But if the order changes then the code won't compile because _m512i or some other type won't be defined.
I was referring to the old implement and test case. Seems like a error introduced before.
I was thinking we may lose the chance to know we change them in wrong order. But it should be OK since we have intrinsic tests. So I agree with you.
mmask64 requires avx512bw. And 32xi16 and 64xi8 aren’t well supported without avx512bw. We used to split them always, but we only split specific instructions now.
We also need avx512bw for the selectb and selectw builtins used for masking.
clang/lib/Headers/gfniintrin.h | ||
---|---|---|
154–155 | Thanks for review! |
This needs to be more like
#if !(defined(_MSC_VER) || defined(SCE)) || __has_feature(modules) || \
We want all intrinsics to be defined for when not compiling for MSVC compatibility. Otherwise using attribute(target) doesn't work.