Skip to content

Commit

Permalink
[X86] Don't define vpclmulqdq or vaes intrinsics in the headers unles…
Browse files Browse the repository at this point in the history
…s avx512fintrin.h has been included.

The intrinsics won't compile unless avx512fintrin.h has declared
the 512 bit types.
  • Loading branch information
topperc committed Mar 28, 2021
1 parent 7b35932 commit 3fb40ce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
10 changes: 5 additions & 5 deletions clang/lib/Headers/immintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@
#include <f16cintrin.h>
#endif

#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
defined(__VPCLMULQDQ__)
#include <vpclmulqdqintrin.h>
#endif

/* No feature check desired due to internal checks */
#include <bmiintrin.h>

Expand Down Expand Up @@ -230,6 +225,11 @@
#include <pkuintrin.h>
#endif

#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
defined(__VPCLMULQDQ__)
#include <vpclmulqdqintrin.h>
#endif

#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
defined(__VAES__)
#include <vaesintrin.h>
Expand Down
41 changes: 21 additions & 20 deletions clang/lib/Headers/vaesintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,47 @@ static __inline__ __m256i __DEFAULT_FN_ATTRS
(__v4di) __B);
}

static __inline__ __m512i __DEFAULT_FN_ATTRS_F
_mm512_aesenc_epi128(__m512i __A, __m512i __B)
{
return (__m512i) __builtin_ia32_aesenc512((__v8di) __A,
(__v8di) __B);
}

static __inline__ __m256i __DEFAULT_FN_ATTRS
_mm256_aesdec_epi128(__m256i __A, __m256i __B)
{
return (__m256i) __builtin_ia32_aesdec256((__v4di) __A,
(__v4di) __B);
}

static __inline__ __m512i __DEFAULT_FN_ATTRS_F
_mm512_aesdec_epi128(__m512i __A, __m512i __B)
static __inline__ __m256i __DEFAULT_FN_ATTRS
_mm256_aesenclast_epi128(__m256i __A, __m256i __B)
{
return (__m512i) __builtin_ia32_aesdec512((__v8di) __A,
(__v8di) __B);
return (__m256i) __builtin_ia32_aesenclast256((__v4di) __A,
(__v4di) __B);
}

static __inline__ __m256i __DEFAULT_FN_ATTRS
_mm256_aesenclast_epi128(__m256i __A, __m256i __B)
_mm256_aesdeclast_epi128(__m256i __A, __m256i __B)
{
return (__m256i) __builtin_ia32_aesenclast256((__v4di) __A,
return (__m256i) __builtin_ia32_aesdeclast256((__v4di) __A,
(__v4di) __B);
}

#ifdef __AVX512FINTRIN_H
static __inline__ __m512i __DEFAULT_FN_ATTRS_F
_mm512_aesenclast_epi128(__m512i __A, __m512i __B)
_mm512_aesenc_epi128(__m512i __A, __m512i __B)
{
return (__m512i) __builtin_ia32_aesenclast512((__v8di) __A,
return (__m512i) __builtin_ia32_aesenc512((__v8di) __A,
(__v8di) __B);
}

static __inline__ __m256i __DEFAULT_FN_ATTRS
_mm256_aesdeclast_epi128(__m256i __A, __m256i __B)
static __inline__ __m512i __DEFAULT_FN_ATTRS_F
_mm512_aesdec_epi128(__m512i __A, __m512i __B)
{
return (__m256i) __builtin_ia32_aesdeclast256((__v4di) __A,
(__v4di) __B);
return (__m512i) __builtin_ia32_aesdec512((__v8di) __A,
(__v8di) __B);
}

static __inline__ __m512i __DEFAULT_FN_ATTRS_F
_mm512_aesenclast_epi128(__m512i __A, __m512i __B)
{
return (__m512i) __builtin_ia32_aesenclast512((__v8di) __A,
(__v8di) __B);
}

static __inline__ __m512i __DEFAULT_FN_ATTRS_F
Expand All @@ -76,7 +77,7 @@ static __inline__ __m512i __DEFAULT_FN_ATTRS_F
return (__m512i) __builtin_ia32_aesdeclast512((__v8di) __A,
(__v8di) __B);
}

#endif // __AVX512FINTRIN_H

#undef __DEFAULT_FN_ATTRS
#undef __DEFAULT_FN_ATTRS_F
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Headers/vpclmulqdqintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
(__v4di)(__m256i)(B), \
(char)(I))

#ifdef __AVX512FINTRIN_H
#define _mm512_clmulepi64_epi128(A, B, I) \
(__m512i)__builtin_ia32_pclmulqdq512((__v8di)(__m512i)(A), \
(__v8di)(__m512i)(B), \
(char)(I))
#endif // __AVX512FINTRIN_H

#endif /* __VPCLMULQDQINTRIN_H */

0 comments on commit 3fb40ce

Please sign in to comment.