diff --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def index d23f638233d3..8b3c579c692b 100644 --- a/clang/include/clang/Basic/BuiltinsX86.def +++ b/clang/include/clang/Basic/BuiltinsX86.def @@ -825,7 +825,9 @@ BUILTIN(__builtin_ia32_cvttps2dq512_mask, "V16iV16fV16iUsIi", "") BUILTIN(__builtin_ia32_cvttps2udq512_mask, "V16iV16fV16iUsIi", "") BUILTIN(__builtin_ia32_cvttpd2dq512_mask, "V8iV8dV8iUcIi", "") BUILTIN(__builtin_ia32_cvttpd2udq512_mask, "V8iV8dV8iUcIi", "") -BUILTIN(__builtin_ia32_cmpps512_mask, "UsV16fV16fIcUsIi", "") +BUILTIN(__builtin_ia32_cmpps512_mask, "UsV16fV16fIiUsIi", "") +BUILTIN(__builtin_ia32_cmpps256_mask, "UcV8fV8fIiUc", "") +BUILTIN(__builtin_ia32_cmpps128_mask, "UcV4fV4fIiUc", "") BUILTIN(__builtin_ia32_pcmpeqb512_mask, "LLiV64cV64cLLi", "") BUILTIN(__builtin_ia32_pcmpeqd512_mask, "sV16iV16is", "") BUILTIN(__builtin_ia32_pcmpeqq512_mask, "cV8LLiV8LLic", "") @@ -850,7 +852,9 @@ BUILTIN(__builtin_ia32_pcmpgtb128_mask, "sV16cV16cs", "") BUILTIN(__builtin_ia32_pcmpgtd128_mask, "cV4iV4ic", "") BUILTIN(__builtin_ia32_pcmpgtq128_mask, "cV2LLiV2LLic", "") BUILTIN(__builtin_ia32_pcmpgtw128_mask, "cV8sV8sc", "") -BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8dIcUcIi", "") +BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8dIiUcIi", "") +BUILTIN(__builtin_ia32_cmppd256_mask, "UcV4dV4dIiUc", "") +BUILTIN(__builtin_ia32_cmppd128_mask, "UcV2dV2dIiUc", "") BUILTIN(__builtin_ia32_rndscaleps_mask, "V16fV16fIiV16fUsIi", "") BUILTIN(__builtin_ia32_rndscalepd_mask, "V8dV8dIiV8dUcIi", "") BUILTIN(__builtin_ia32_cvtps2dq512_mask, "V16iV16fV16iUsIi", "") diff --git a/clang/lib/Headers/avx512vlintrin.h b/clang/lib/Headers/avx512vlintrin.h index e28025ba7a00..9de0cf418b78 100644 --- a/clang/lib/Headers/avx512vlintrin.h +++ b/clang/lib/Headers/avx512vlintrin.h @@ -1277,4 +1277,43 @@ _mm_maskz_xor_epi64 (__mmask8 __U, __m128i __A, __m128i __B) (__v4di)(__m256i)(b), \ (p), (__mmask8)(m)); }) +#define _mm256_cmp_ps_mask(a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmpps256_mask((__v8sf)(__m256)(a), \ + (__v8sf)(__m256)(b), \ + (p), (__mmask8)-1); }) + +#define _mm256_mask_cmp_ps_mask(m, a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmpps256_mask((__v8sf)(__m256)(a), \ + (__v8sf)(__m256)(b), \ + (p), (__mmask8)(m)); }) + +#define _mm256_cmp_pd_mask(a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmppd256_mask((__v4df)(__m256)(a), \ + (__v4df)(__m256)(b), \ + (p), (__mmask8)-1); }) + +#define _mm256_mask_cmp_pd_mask(m, a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmppd256_mask((__v4df)(__m256)(a), \ + (__v4df)(__m256)(b), \ + (p), (__mmask8)(m)); }) + +#define _mm128_cmp_ps_mask(a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmpps128_mask((__v4sf)(__m128)(a), \ + (__v4sf)(__m128)(b), \ + (p), (__mmask8)-1); }) + +#define _mm128_mask_cmp_ps_mask(m, a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmpps128_mask((__v4sf)(__m128)(a), \ + (__v4sf)(__m128)(b), \ + (p), (__mmask8)(m)); }) + +#define _mm128_cmp_pd_mask(a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmppd128_mask((__v2df)(__m128)(a), \ + (__v2df)(__m128)(b), \ + (p), (__mmask8)-1); }) + +#define _mm128_mask_cmp_pd_mask(m, a, b, p) __extension__ ({ \ + (__mmask8)__builtin_ia32_cmppd128_mask((__v2df)(__m128)(a), \ + (__v2df)(__m128)(b), \ + (p), (__mmask8)(m)); }) #endif /* __AVX512VLINTRIN_H */ diff --git a/clang/test/CodeGen/avx512vl-builtins.c b/clang/test/CodeGen/avx512vl-builtins.c index 99cab9100adb..e9b65ae0e893 100644 --- a/clang/test/CodeGen/avx512vl-builtins.c +++ b/clang/test/CodeGen/avx512vl-builtins.c @@ -1074,3 +1074,50 @@ __m128i test_mm_maskz_xor_epi64 (__mmask8 __U, __m128i __A, __m128i __B) { return _mm_maskz_xor_epi64( __U, __A, __B); } +__mmask8 test_mm256_cmp_ps_mask(__m256 __A, __m256 __B) { + // CHECK-LABEL: @test_mm256_cmp_ps_mask + // CHECK: @llvm.x86.avx512.mask.cmp.ps.256 + return (__mmask8)_mm256_cmp_ps_mask(__A, __B, 0); +} + +__mmask8 test_mm256_mask_cmp_ps_mask(__mmask8 m, __m256 __A, __m256 __B) { + // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask + // CHECK: @llvm.x86.avx512.mask.cmp.ps.256 + return _mm256_mask_cmp_ps_mask(m, __A, __B, 0); +} + +__mmask8 test_mm128_cmp_ps_mask(__m128 __A, __m128 __B) { + // CHECK-LABEL: @test_mm128_cmp_ps_mask + // CHECK: @llvm.x86.avx512.mask.cmp.ps.128 + return (__mmask8)_mm128_cmp_ps_mask(__A, __B, 0); +} + +__mmask8 test_mm128_mask_cmp_ps_mask(__mmask8 m, __m128 __A, __m128 __B) { + // CHECK-LABEL: @test_mm128_mask_cmp_ps_mask + // CHECK: @llvm.x86.avx512.mask.cmp.ps.128 + return _mm128_mask_cmp_ps_mask(m, __A, __B, 0); +} + +__mmask8 test_mm256_cmp_pd_mask(__m256d __A, __m256d __B) { + // CHECK-LABEL: @test_mm256_cmp_pd_mask + // CHECK: @llvm.x86.avx512.mask.cmp.pd.256 + return (__mmask8)_mm256_cmp_pd_mask(__A, __B, 0); +} + +__mmask8 test_mm256_mask_cmp_pd_mask(__mmask8 m, __m256d __A, __m256d __B) { + // CHECK-LABEL: @test_mm256_mask_cmp_pd_mask + // CHECK: @llvm.x86.avx512.mask.cmp.pd.256 + return _mm256_mask_cmp_pd_mask(m, __A, __B, 0); +} + +__mmask8 test_mm128_cmp_pd_mask(__m128d __A, __m128d __B) { + // CHECK-LABEL: @test_mm128_cmp_pd_mask + // CHECK: @llvm.x86.avx512.mask.cmp.pd.128 + return (__mmask8)_mm128_cmp_pd_mask(__A, __B, 0); +} + +__mmask8 test_mm128_mask_cmp_pd_mask(__mmask8 m, __m128d __A, __m128d __B) { + // CHECK-LABEL: @test_mm128_mask_cmp_pd_mask + // CHECK: @llvm.x86.avx512.mask.cmp.pd.128 + return _mm128_mask_cmp_pd_mask(m, __A, __B, 0); +}