Index: include/clang/Basic/BuiltinsX86.def =================================================================== --- include/clang/Basic/BuiltinsX86.def +++ include/clang/Basic/BuiltinsX86.def @@ -2151,6 +2151,14 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask, "V2dV2dV2dV2dUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_maskz, "V2dV2dV2dV2dUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask3, "V2dV2dV2dV2dUcIi", "", "avx512f") +TARGET_BUILTIN(__builtin_ia32_kandhi, "UsUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_kandnhi, "UsUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_korhi, "UsUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_kortestchi, "iUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_kortestzhi, "iUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_kunpckhi, "UsUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_kxnorhi, "UsUsUs","","avx512f") +TARGET_BUILTIN(__builtin_ia32_kxorhi, "UsUsUs","","avx512f") #undef BUILTIN #undef TARGET_BUILTIN Index: lib/Headers/avx512fintrin.h =================================================================== --- lib/Headers/avx512fintrin.h +++ lib/Headers/avx512fintrin.h @@ -7048,6 +7048,56 @@ __R);\ }) +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kand (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kandhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kandn (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kandnhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kor (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_korhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ int __DEFAULT_FN_ATTRS +_mm512_kortestc (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kortestchi ((__mmask16) __A, + (__mmask16) __B); +} + +static __inline__ int __DEFAULT_FN_ATTRS +_mm512_kortestz (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kortestzhi ((__mmask16) __A, + (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kunpackb (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kxnor (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kxnorhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kxor (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kxorhi ((__mmask16) __A, (__mmask16) __B); +} + #undef __DEFAULT_FN_ATTRS #endif // __AVX512FINTRIN_H Index: test/CodeGen/avx512f-builtins.c =================================================================== --- test/CodeGen/avx512f-builtins.c +++ test/CodeGen/avx512f-builtins.c @@ -4801,3 +4801,51 @@ // CHECK: @llvm.x86.avx512.mask3.vfmadd.sd return _mm_mask3_fnmsub_round_sd(__W, __X, __Y, __U, _MM_FROUND_CUR_DIRECTION); } + +__mmask16 test_mm512_kand(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kand + // CHECK: @llvm.x86.avx512.kand.w + return _mm512_kand(__A, __B); +} + +__mmask16 test_mm512_kandn(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kandn + // CHECK: @llvm.x86.avx512.kandn.w + return _mm512_kandn(__A, __B); +} + +__mmask16 test_mm512_kor(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kor + // CHECK: @llvm.x86.avx512.kor.w + return _mm512_kor(__A, __B); +} + +int test_mm512_kortestc(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kortestc + // CHECK: @llvm.x86.avx512.kortestc.w + return _mm512_kortestc(__A, __B); +} + +int test_mm512_kortestz(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kortestz + // CHECK: @llvm.x86.avx512.kortestz.w + return _mm512_kortestz(__A, __B); +} + +__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kunpackb + // CHECK: @llvm.x86.avx512.kunpck.bw + return _mm512_kunpackb(__A, __B); +} + +__mmask16 test_mm512_kxnor(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kxnor + // CHECK: @llvm.x86.avx512.kxnor.w + return _mm512_kxnor(__A, __B); +} + +__mmask16 test_mm512_kxor(__mmask16 __A, __mmask16 __B) { + // CHECK-LABEL: @test_mm512_kxor + // CHECK: @llvm.x86.avx512.kxor.w + return _mm512_kxor(__A, __B); +}