diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 12 | ||||
| -rw-r--r-- | clang/test/CodeGen/avx512f-builtins.c | 24 |
2 files changed, 30 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index b4ae779bf51..312714c5072 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -8710,6 +8710,18 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, return EmitX86MaskedCompare(*this, CC, false, Ops); } + case X86::BI__builtin_ia32_kortestchi: + case X86::BI__builtin_ia32_kortestzhi: { + Value *Or = EmitX86MaskLogic(*this, Instruction::Or, 16, Ops); + Value *C; + if (BuiltinID == X86::BI__builtin_ia32_kortestchi) + C = llvm::Constant::getAllOnesValue(Builder.getInt16Ty()); + else + C = llvm::Constant::getNullValue(Builder.getInt16Ty()); + Value *Cmp = Builder.CreateICmpEQ(Or, C); + return Builder.CreateZExt(Cmp, ConvertType(E->getType())); + } + case X86::BI__builtin_ia32_kandhi: return EmitX86MaskLogic(*this, Instruction::And, 16, Ops); case X86::BI__builtin_ia32_kandnhi: diff --git a/clang/test/CodeGen/avx512f-builtins.c b/clang/test/CodeGen/avx512f-builtins.c index 35a97912c71..67522a36e2b 100644 --- a/clang/test/CodeGen/avx512f-builtins.c +++ b/clang/test/CodeGen/avx512f-builtins.c @@ -6247,16 +6247,28 @@ __mmask16 test_mm512_kor(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m __E, __F); } -int test_mm512_kortestc(__mmask16 __A, __mmask16 __B) { +int test_mm512_kortestc(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: @test_mm512_kortestc - // CHECK: @llvm.x86.avx512.kortestc.w - return _mm512_kortestc(__A, __B); + // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> + // CHECK: [[RHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> + // CHECK: [[OR:%.*]] = or <16 x i1> [[LHS]], [[RHS]] + // CHECK: [[CAST:%.*]] = bitcast <16 x i1> [[OR]] to i16 + // CHECK: [[CMP:%.*]] = icmp eq i16 [[CAST]], -1 + // CHECK: zext i1 [[CMP]] to i32 + return _mm512_kortestc(_mm512_cmpneq_epu32_mask(__A, __B), + _mm512_cmpneq_epu32_mask(__C, __D)); } -int test_mm512_kortestz(__mmask16 __A, __mmask16 __B) { +int test_mm512_kortestz(__m512i __A, __m512i __B, __m512i __C, __m512i __D) { // CHECK-LABEL: @test_mm512_kortestz - // CHECK: @llvm.x86.avx512.kortestz.w - return _mm512_kortestz(__A, __B); + // CHECK: [[LHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> + // CHECK: [[RHS:%.*]] = bitcast i16 %{{.*}} to <16 x i1> + // CHECK: [[OR:%.*]] = or <16 x i1> [[LHS]], [[RHS]] + // CHECK: [[CAST:%.*]] = bitcast <16 x i1> [[OR]] to i16 + // CHECK: [[CMP:%.*]] = icmp eq i16 [[CAST]], 0 + // CHECK: zext i1 [[CMP]] to i32 + return _mm512_kortestz(_mm512_cmpneq_epu32_mask(__A, __B), + _mm512_cmpneq_epu32_mask(__C, __D)); } __mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) { |

