Index: include/clang/Basic/BuiltinsX86.def =================================================================== --- include/clang/Basic/BuiltinsX86.def +++ include/clang/Basic/BuiltinsX86.def @@ -1983,6 +1983,18 @@ TARGET_BUILTIN(__builtin_ia32_cvtmask2q256, "V4LLiUc","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_cvtq2mask128, "UcV2LLi","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,avx512vl") +TARGET_BUILTIN(__builtin_ia32_broadcastmb512, "V8LLiUc","","avx512cd") +TARGET_BUILTIN(__builtin_ia32_broadcastmw512, "V16iUs","","avx512cd") +TARGET_BUILTIN(__builtin_ia32_broadcastf32x4_512, "V16fV4fV16fUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_broadcastf64x4_512, "V8dV4dV8dUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_broadcasti32x4_512, "V16iV4iV16iUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_broadcasti64x4_512, "V8LLiV4LLiV8LLiUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_broadcastsd512, "V8dV2dV8dUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_broadcastss512, "V16fV4fV16fUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_broadcastmb128, "V2LLiUc","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_broadcastmb256, "V4LLiUc","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_broadcastmw128, "V4iUs","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_broadcastmw256, "V8iUs","","avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcastf32x2_512_mask, "V16fV4fV16fUs","","avx512dq") TARGET_BUILTIN(__builtin_ia32_broadcastf32x8_512_mask, "V16fV8fV16fUs","","avx512dq") TARGET_BUILTIN(__builtin_ia32_broadcastf64x2_512_mask, "V8dV2dV8dUc","","avx512dq") Index: lib/Headers/avx512cdintrin.h =================================================================== --- lib/Headers/avx512cdintrin.h +++ lib/Headers/avx512cdintrin.h @@ -126,6 +126,19 @@ (__v8di) _mm512_setzero_si512 (), (__mmask8) __U); } + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_broadcastmb_epi64 (__mmask8 __A) +{ + return (__m512i) __builtin_ia32_broadcastmb512 (__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_broadcastmw_epi32 (__mmask16 __A) +{ + return (__m512i) __builtin_ia32_broadcastmw512 (__A); +} + #undef __DEFAULT_FN_ATTRS #endif Index: lib/Headers/avx512fintrin.h =================================================================== --- lib/Headers/avx512fintrin.h +++ lib/Headers/avx512fintrin.h @@ -5619,6 +5619,142 @@ __R);\ }) +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_broadcast_f32x4 (__m128 __A) +{ + return (__m512) __builtin_ia32_broadcastf32x4_512 ((__v4sf) __A, + (__v16sf) + _mm512_undefined_ps (), + (__mmask16) -1); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_mask_broadcast_f32x4 (__m512 __O, __mmask16 __M, __m128 __A) +{ + return (__m512) __builtin_ia32_broadcastf32x4_512 ((__v4sf) __A, + (__v16sf) __O, + __M); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_maskz_broadcast_f32x4 (__mmask16 __M, __m128 __A) +{ + return (__m512) __builtin_ia32_broadcastf32x4_512 ((__v4sf) __A, + (__v16sf) + _mm512_setzero_ps (), + __M); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS +_mm512_broadcast_f64x4 (__m256d __A) +{ + return (__m512d) __builtin_ia32_broadcastf64x4_512 ((__v4df) __A, + (__v8df) + _mm512_undefined_pd (), + (__mmask8) -1); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS +_mm512_mask_broadcast_f64x4 (__m512d __O, __mmask8 __M, __m256d __A) +{ + return (__m512d) __builtin_ia32_broadcastf64x4_512 ((__v4df) __A, + (__v8df) __O, + __M); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS +_mm512_maskz_broadcast_f64x4 (__mmask8 __M, __m256d __A) +{ + return (__m512d) __builtin_ia32_broadcastf64x4_512 ((__v4df) __A, + (__v8df) + _mm512_setzero_pd (), + __M); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_broadcast_i32x4 (__m128i __A) +{ + return (__m512i) __builtin_ia32_broadcasti32x4_512 ((__v4si) __A, + (__v16si) + _mm512_undefined_epi32 (), + (__mmask16) -1); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_broadcast_i32x4 (__m512i __O, __mmask16 __M, __m128i __A) +{ + return (__m512i) __builtin_ia32_broadcasti32x4_512 ((__v4si) __A, + (__v16si) __O, + __M); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_broadcast_i32x4 (__mmask16 __M, __m128i __A) +{ + return (__m512i) __builtin_ia32_broadcasti32x4_512 ((__v4si) __A, + (__v16si) + _mm512_setzero_si512 (), + __M); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_broadcast_i64x4 (__m256i __A) +{ + return (__m512i) __builtin_ia32_broadcasti64x4_512 ((__v4di) __A, + (__v8di) + _mm512_undefined_epi32 (), + (__mmask8) -1); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_broadcast_i64x4 (__m512i __O, __mmask8 __M, __m256i __A) +{ + return (__m512i) __builtin_ia32_broadcasti64x4_512 ((__v4di) __A, + (__v8di) __O, + __M); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_broadcast_i64x4 (__mmask8 __M, __m256i __A) +{ + return (__m512i) __builtin_ia32_broadcasti64x4_512 ((__v4di) __A, + (__v8di) + _mm512_setzero_si512 (), + __M); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS +_mm512_mask_broadcastsd_pd (__m512d __O, __mmask8 __M, __m128d __A) +{ + return (__m512d) __builtin_ia32_broadcastsd512 ((__v2df) __A, + (__v8df) __O, __M); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS +_mm512_maskz_broadcastsd_pd (__mmask8 __M, __m128d __A) +{ + return (__m512d) __builtin_ia32_broadcastsd512 ((__v2df) __A, + (__v8df) + _mm512_setzero_pd (), + __M); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_mask_broadcastss_ps (__m512 __O, __mmask16 __M, __m128 __A) +{ + return (__m512) __builtin_ia32_broadcastss512 ((__v4sf) __A, + (__v16sf) __O, __M); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_maskz_broadcastss_ps (__mmask16 __M, __m128 __A) +{ + return (__m512) __builtin_ia32_broadcastss512 ((__v4sf) __A, + (__v16sf) + _mm512_setzero_ps (), + __M); +} + static __inline__ __m128i __DEFAULT_FN_ATTRS _mm512_cvtsepi32_epi8 (__m512i __A) { Index: lib/Headers/avx512vlintrin.h =================================================================== --- lib/Headers/avx512vlintrin.h +++ lib/Headers/avx512vlintrin.h @@ -6004,6 +6004,29 @@ (__mmask8) __U); } +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_broadcastmb_epi64 (__mmask8 __A) +{ + return (__m128i) __builtin_ia32_broadcastmb128 (__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm256_broadcastmb_epi64 (__mmask8 __A) +{ + return (__m256i) __builtin_ia32_broadcastmb256 (__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_broadcastmw_epi32 (__mmask16 __A) +{ + return (__m128i) __builtin_ia32_broadcastmw128 (__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm256_broadcastmw_epi32 (__mmask16 __A) +{ + return (__m256i) __builtin_ia32_broadcastmw256 (__A); +} #define _mm_mask_set1_epi32( __O, __M, __A) __extension__ ({ \ __builtin_ia32_pbroadcastd128_gpr_mask (__A, (__v4si)( __O),\ Index: test/CodeGen/avx512cdintrin.c =================================================================== --- test/CodeGen/avx512cdintrin.c +++ test/CodeGen/avx512cdintrin.c @@ -65,3 +65,15 @@ // CHECK: @llvm.x86.avx512.mask.lzcnt.q.512 return _mm512_maskz_lzcnt_epi64(__U,__A); } + +__m512i test_mm512_broadcastmb_epi64(__mmask8 __A) { + // CHECK-LABEL: @test_mm512_broadcastmb_epi64 + // CHECK: @llvm.x86.avx512.broadcastmb.512 + return _mm512_broadcastmb_epi64(__A); +} + +__m512i test_mm512_broadcastmw_epi32(__mmask16 __A) { + // CHECK-LABEL: @test_mm512_broadcastmw_epi32 + // CHECK: @llvm.x86.avx512.broadcastmw.512 + return _mm512_broadcastmw_epi32(__A); +} Index: test/CodeGen/avx512f-builtins.c =================================================================== --- test/CodeGen/avx512f-builtins.c +++ test/CodeGen/avx512f-builtins.c @@ -3700,6 +3700,102 @@ return _mm_maskz_sqrt_round_ss(__U,__A,__B,_MM_FROUND_CUR_DIRECTION); } +__m512 test_mm512_broadcast_f32x4(__m128 __A) { + // CHECK-LABEL: @test_mm512_broadcast_f32x4 + // CHECK: @llvm.x86.avx512.mask.broadcastf32x4 + return _mm512_broadcast_f32x4(__A); +} + +__m512 test_mm512_mask_broadcast_f32x4(__m512 __O, __mmask16 __M, __m128 __A) { + // CHECK-LABEL: @test_mm512_mask_broadcast_f32x4 + // CHECK: @llvm.x86.avx512.mask.broadcastf32x4 + return _mm512_mask_broadcast_f32x4(__O, __M, __A); +} + +__m512 test_mm512_maskz_broadcast_f32x4(__mmask16 __M, __m128 __A) { + // CHECK-LABEL: @test_mm512_maskz_broadcast_f32x4 + // CHECK: @llvm.x86.avx512.mask.broadcastf32x4 + return _mm512_maskz_broadcast_f32x4(__M, __A); +} + +__m512d test_mm512_broadcast_f64x4(__m256d __A) { + // CHECK-LABEL: @test_mm512_broadcast_f64x4 + // CHECK: @llvm.x86.avx512.mask.broadcastf64x4 + return _mm512_broadcast_f64x4(__A); +} + +__m512d test_mm512_mask_broadcast_f64x4(__m512d __O, __mmask8 __M, __m256d __A) { + // CHECK-LABEL: @test_mm512_mask_broadcast_f64x4 + // CHECK: @llvm.x86.avx512.mask.broadcastf64x4 + return _mm512_mask_broadcast_f64x4(__O, __M, __A); +} + +__m512d test_mm512_maskz_broadcast_f64x4(__mmask8 __M, __m256d __A) { + // CHECK-LABEL: @test_mm512_maskz_broadcast_f64x4 + // CHECK: @llvm.x86.avx512.mask.broadcastf64x4 + return _mm512_maskz_broadcast_f64x4(__M, __A); +} + +__m512i test_mm512_broadcast_i32x4(__m128i __A) { + // CHECK-LABEL: @test_mm512_broadcast_i32x4 + // CHECK: @llvm.x86.avx512.mask.broadcasti32x4 + return _mm512_broadcast_i32x4(__A); +} + +__m512i test_mm512_mask_broadcast_i32x4(__m512i __O, __mmask16 __M, __m128i __A) { + // CHECK-LABEL: @test_mm512_mask_broadcast_i32x4 + // CHECK: @llvm.x86.avx512.mask.broadcasti32x4 + return _mm512_mask_broadcast_i32x4(__O, __M, __A); +} + +__m512i test_mm512_maskz_broadcast_i32x4(__mmask16 __M, __m128i __A) { + // CHECK-LABEL: @test_mm512_maskz_broadcast_i32x4 + // CHECK: @llvm.x86.avx512.mask.broadcasti32x4 + return _mm512_maskz_broadcast_i32x4(__M, __A); +} + +__m512i test_mm512_broadcast_i64x4(__m256i __A) { + // CHECK-LABEL: @test_mm512_broadcast_i64x4 + // CHECK: @llvm.x86.avx512.mask.broadcasti64x4 + return _mm512_broadcast_i64x4(__A); +} + +__m512i test_mm512_mask_broadcast_i64x4(__m512i __O, __mmask8 __M, __m256i __A) { + // CHECK-LABEL: @test_mm512_mask_broadcast_i64x4 + // CHECK: @llvm.x86.avx512.mask.broadcasti64x4 + return _mm512_mask_broadcast_i64x4(__O, __M, __A); +} + +__m512i test_mm512_maskz_broadcast_i64x4(__mmask8 __M, __m256i __A) { + // CHECK-LABEL: @test_mm512_maskz_broadcast_i64x4 + // CHECK: @llvm.x86.avx512.mask.broadcasti64x4 + return _mm512_maskz_broadcast_i64x4(__M, __A); +} + +__m512d test_mm512_mask_broadcastsd_pd(__m512d __O, __mmask8 __M, __m128d __A) { + // CHECK-LABEL: @test_mm512_mask_broadcastsd_pd + // CHECK: @llvm.x86.avx512.mask.broadcast.sd.pd.512 + return _mm512_mask_broadcastsd_pd(__O, __M, __A); +} + +__m512d test_mm512_maskz_broadcastsd_pd(__mmask8 __M, __m128d __A) { + // CHECK-LABEL: @test_mm512_maskz_broadcastsd_pd + // CHECK: @llvm.x86.avx512.mask.broadcast.sd.pd.512 + return _mm512_maskz_broadcastsd_pd(__M, __A); +} + +__m512 test_mm512_mask_broadcastss_ps(__m512 __O, __mmask16 __M, __m128 __A) { + // CHECK-LABEL: @test_mm512_mask_broadcastss_ps + // CHECK: @llvm.x86.avx512.mask.broadcast.ss.ps.512 + return _mm512_mask_broadcastss_ps(__O, __M, __A); +} + +__m512 test_mm512_maskz_broadcastss_ps(__mmask16 __M, __m128 __A) { + // CHECK-LABEL: @test_mm512_maskz_broadcastss_ps + // CHECK: @llvm.x86.avx512.mask.broadcast.ss.ps.512 + return _mm512_maskz_broadcastss_ps(__M, __A); +} + __m128i test_mm512_cvtsepi32_epi8(__m512i __A) { // CHECK-LABEL: @test_mm512_cvtsepi32_epi8 // CHECK: @llvm.x86.avx512.mask.pmovs.db.512 Index: test/CodeGen/avx512vl-builtins.c =================================================================== --- test/CodeGen/avx512vl-builtins.c +++ test/CodeGen/avx512vl-builtins.c @@ -4026,6 +4026,30 @@ return _mm256_mask_movedup_pd(__W, __U, __A); } +__m128i test_mm_broadcastmb_epi64(__mmask8 __A) { + // CHECK-LABEL: @test_mm_broadcastmb_epi64 + // CHECK: @llvm.x86.avx512.broadcastmb.128 + return _mm_broadcastmb_epi64(__A); +} + +__m256i test_mm256_broadcastmb_epi64(__mmask8 __A) { + // CHECK-LABEL: @test_mm256_broadcastmb_epi64 + // CHECK: @llvm.x86.avx512.broadcastmb.256 + return _mm256_broadcastmb_epi64(__A); +} + +__m128i test_mm_broadcastmw_epi32(__mmask16 __A) { + // CHECK-LABEL: @test_mm_broadcastmw_epi32 + // CHECK: @llvm.x86.avx512.broadcastmw.128 + return _mm_broadcastmw_epi32(__A); +} + +__m256i test_mm256_broadcastmw_epi32(__mmask16 __A) { + // CHECK-LABEL: @test_mm256_broadcastmw_epi32 + // CHECK: @llvm.x86.avx512.broadcastmw.256 + return _mm256_broadcastmw_epi32(__A); +} + __m256d test_mm256_maskz_movedup_pd(__mmask8 __U, __m256d __A) { // CHECK-LABEL: @test_mm256_maskz_movedup_pd // CHECK: @llvm.x86.avx512.mask.movddup.256