From f557b09f142c69c725a55b750bb8e4382657fc9c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 19 Jan 2015 01:18:19 +0000 Subject: [PATCH] [x86] Mark that the AVX-512 cmpps/cmppd builtins need an ICE for the comparison immediate. This requires converting to a macro in the header file. llvm-svn: 226421 --- clang/include/clang/Basic/BuiltinsX86.def | 4 ++-- clang/lib/Headers/avx512fintrin.h | 29 +++++++++++++---------------- clang/test/CodeGen/avx512f-builtins.c | 12 ++++++++++++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def index 545638ea..3aea221 100644 --- a/clang/include/clang/Basic/BuiltinsX86.def +++ b/clang/include/clang/Basic/BuiltinsX86.def @@ -842,7 +842,7 @@ BUILTIN(__builtin_ia32_cvttps2dq512_mask, "V16iV16fV16iUsiC", "") BUILTIN(__builtin_ia32_cvttps2udq512_mask, "V16iV16fV16iUsiC", "") BUILTIN(__builtin_ia32_cvttpd2dq512_mask, "V8iV8dV8iUciC", "") BUILTIN(__builtin_ia32_cvttpd2udq512_mask, "V8iV8dV8iUciC", "") -BUILTIN(__builtin_ia32_cmpps512_mask, "UsV16fV16fiCUsi", "") +BUILTIN(__builtin_ia32_cmpps512_mask, "UsV16fV16fIiUsi", "") BUILTIN(__builtin_ia32_pcmpeqb512_mask, "LLiV64cV64cLLi", "") BUILTIN(__builtin_ia32_pcmpeqd512_mask, "sV16iV16is", "") BUILTIN(__builtin_ia32_pcmpeqq512_mask, "cV8LLiV8LLic", "") @@ -855,7 +855,7 @@ BUILTIN(__builtin_ia32_pcmpeqb128_mask, "sV16cV16cs", "") BUILTIN(__builtin_ia32_pcmpeqd128_mask, "cV4iV4ic", "") BUILTIN(__builtin_ia32_pcmpeqq128_mask, "cV2LLiV2LLic", "") BUILTIN(__builtin_ia32_pcmpeqw128_mask, "cV8sV8sc", "") -BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8diCUci", "") +BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8dIiUci", "") BUILTIN(__builtin_ia32_rndscaleps_mask, "V16fV16fiCV16fUsiC", "") BUILTIN(__builtin_ia32_rndscalepd_mask, "V8dV8diCV8dUciC", "") BUILTIN(__builtin_ia32_cvtps2dq512_mask, "V16iV16fV16iUsiC", "") diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h index 4b19590..e6f128d 100644 --- a/clang/lib/Headers/avx512fintrin.h +++ b/clang/lib/Headers/avx512fintrin.h @@ -669,22 +669,19 @@ _mm512_mask_blend_epi32(__mmask16 __U, __m512i __A, __m512i __W) /* Compare */ -static __inline __mmask16 __attribute__ ((__always_inline__, __nodebug__)) -_mm512_cmp_ps_mask(__m512 a, __m512 b, const int p) -{ - return (__mmask16) __builtin_ia32_cmpps512_mask ((__v16sf) a, - (__v16sf) b, p, (__mmask16) -1, - _MM_FROUND_CUR_DIRECTION); -} - -static __inline __mmask8 __attribute__ ((__always_inline__, __nodebug__)) -_mm512_cmp_pd_mask(__m512d __X, __m512d __Y, const int __P) -{ - return (__mmask8) __builtin_ia32_cmppd512_mask ((__v8df) __X, - (__v8df) __Y, __P, - (__mmask8) -1, - _MM_FROUND_CUR_DIRECTION); -} +#define _mm512_cmp_ps_mask(a, b, p) __extension__ ({ \ + __m512 __a = (a); \ + __m512 __b = (b); \ + (__mmask16)__builtin_ia32_cmpps512_mask((__v16sf)__a, (__v16sf)__b, (p), \ + (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION); }) + +#define _mm512_cmp_pd_mask(a, b, p) __extension__ ({ \ + __m512 __a = (a); \ + __m512 __b = (b); \ + (__mmask8)__builtin_ia32_cmppd512_mask((__v8df)__a, (__v8df)__b, (p), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION); }) /* Conversion */ diff --git a/clang/test/CodeGen/avx512f-builtins.c b/clang/test/CodeGen/avx512f-builtins.c index d63f53d..5caf314 100644 --- a/clang/test/CodeGen/avx512f-builtins.c +++ b/clang/test/CodeGen/avx512f-builtins.c @@ -252,3 +252,15 @@ __m512 test_mm512_unpacklo_ps(__m512 a, __m512 b) // CHECK: shufflevector <16 x float> {{.*}} return _mm512_unpacklo_ps(a, b); } + +__mmask16 test_mm512_cmp_ps_mask(__m512 __a, __m512 __b) { + // CHECK-LABEL: @test_mm512_cmp_ps_mask + // CHECK: @llvm.x86.avx512.mask.cmp.ps.512 + return _mm512_cmp_ps_mask(__a, __b, 0); +} + +__mmask8 test_mm512_cmp_pd_mask(__m512 __a, __m512 __b) { + // CHECK-LABEL: @test_mm512_cmp_pd_mask + // CHECK: @llvm.x86.avx512.mask.cmp.pd.512 + return _mm512_cmp_pd_mask(__a, __b, 0); +} -- 2.7.4