// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fclangir -emit-cir -o %t.cir -Wall -Werror // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fclangir -emit-llvm -o %t.ll -Wall -Werror // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512bw -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG // This test mimics clang/test/CodeGen/X86/avx512bw-builtins.c, which eventually // CIR shall be able to support fully. #include __mmask32 test_kshiftli_mask32(__mmask32 A) { // CIR-LABEL: test_kshiftli_mask32 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<32 x !cir.int> // CIR: %{{.*}} = cir.vec.shuffle([[SHIFT]], [[VAL]] : !cir.vector<32 x !cir.int>) [#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i, #cir.int<6> : !s32i, #cir.int<7> : !s32i, #cir.int<8> : !s32i, #cir.int<9> : !s32i, #cir.int<10> : !s32i, #cir.int<11> : !s32i, #cir.int<12> : !s32i, #cir.int<13> : !s32i, #cir.int<14> : !s32i, #cir.int<15> : !s32i, #cir.int<16> : !s32i, #cir.int<17> : !s32i, #cir.int<18> : !s32i, #cir.int<19> : !s32i, #cir.int<20> : !s32i, #cir.int<21> : !s32i, #cir.int<22> : !s32i, #cir.int<23> : !s32i, #cir.int<24> : !s32i, #cir.int<25> : !s32i, #cir.int<26> : !s32i, #cir.int<27> : !s32i, #cir.int<28> : !s32i, #cir.int<29> : !s32i, #cir.int<30> : !s32i, #cir.int<31> : !s32i, #cir.int<32> : !s32i] : !cir.vector<32 x !cir.int> // LLVM-LABEL: test_kshiftli_mask32 // LLVM: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[RES:%.*]] = shufflevector <32 x i1> zeroinitializer, <32 x i1> [[VAL]], <32 x i32> // OGCG-LABEL: test_kshiftli_mask32 // OGCG: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // OGCG: [[RES:%.*]] = shufflevector <32 x i1> zeroinitializer, <32 x i1> [[VAL]], <32 x i32> return _kshiftli_mask32(A, 31); } __mmask32 test_kshiftri_mask32(__mmask32 A) { // CIR-LABEL: test_kshiftri_mask32 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<32 x !cir.int> // CIR: %{{.*}} = cir.vec.shuffle([[VAL]], [[SHIFT]] : !cir.vector<32 x !cir.int>) [#cir.int<31> : !s32i, #cir.int<32> : !s32i, #cir.int<33> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<48> : !s32i, #cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i] : !cir.vector<32 x !cir.int> // LLVM-LABEL: test_kshiftri_mask32 // LLVM: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[RES:%.*]] = shufflevector <32 x i1> [[VAL]], <32 x i1> zeroinitializer, <32 x i32> // OGCG-LABEL: test_kshiftri_mask32 // OGCG: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // OGCG: [[RES:%.*]] = shufflevector <32 x i1> [[VAL]], <32 x i1> zeroinitializer, <32 x i32> return _kshiftri_mask32(A, 31); } __mmask64 test_kshiftli_mask64(__mmask64 A) { // CIR-LABEL: test_kshiftli_mask64 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<64 x !cir.int> // CIR: %{{.*}} = cir.vec.shuffle([[SHIFT]], [[VAL]] : !cir.vector<64 x !cir.int>) [#cir.int<32> : !s32i, #cir.int<33> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<48> : !s32i, #cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i, #cir.int<63> : !s32i, #cir.int<64> : !s32i, #cir.int<65> : !s32i, #cir.int<66> : !s32i, #cir.int<67> : !s32i, #cir.int<68> : !s32i, #cir.int<69> : !s32i, #cir.int<70> : !s32i, #cir.int<71> : !s32i, #cir.int<72> : !s32i, #cir.int<73> : !s32i, #cir.int<74> : !s32i, #cir.int<75> : !s32i, #cir.int<76> : !s32i, #cir.int<77> : !s32i, #cir.int<78> : !s32i, #cir.int<79> : !s32i, #cir.int<80> : !s32i, #cir.int<81> : !s32i, #cir.int<82> : !s32i, #cir.int<83> : !s32i, #cir.int<84> : !s32i, #cir.int<85> : !s32i, #cir.int<86> : !s32i, #cir.int<87> : !s32i, #cir.int<88> : !s32i, #cir.int<89> : !s32i, #cir.int<90> : !s32i, #cir.int<91> : !s32i, #cir.int<92> : !s32i, #cir.int<93> : !s32i, #cir.int<94> : !s32i, #cir.int<95> : !s32i] : !cir.vector<64 x !cir.int> // LLVM-LABEL: test_kshiftli_mask64 // LLVM: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[RES:%.*]] = shufflevector <64 x i1> zeroinitializer, <64 x i1> [[VAL]], <64 x i32> // OGCG-LABEL: test_kshiftli_mask64 // OGCG: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // OGCG: [[RES:%.*]] = shufflevector <64 x i1> zeroinitializer, <64 x i1> [[VAL]], <64 x i32> return _kshiftli_mask64(A, 32); } __mmask64 test_kshiftri_mask64(__mmask64 A) { // CIR-LABEL: test_kshiftri_mask64 // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<64 x !cir.int> // CIR: %{{.*}} = cir.vec.shuffle([[VAL]], [[SHIFT]] : !cir.vector<64 x !cir.int>) [#cir.int<32> : !s32i, #cir.int<33> : !s32i, #cir.int<34> : !s32i, #cir.int<35> : !s32i, #cir.int<36> : !s32i, #cir.int<37> : !s32i, #cir.int<38> : !s32i, #cir.int<39> : !s32i, #cir.int<40> : !s32i, #cir.int<41> : !s32i, #cir.int<42> : !s32i, #cir.int<43> : !s32i, #cir.int<44> : !s32i, #cir.int<45> : !s32i, #cir.int<46> : !s32i, #cir.int<47> : !s32i, #cir.int<48> : !s32i, #cir.int<49> : !s32i, #cir.int<50> : !s32i, #cir.int<51> : !s32i, #cir.int<52> : !s32i, #cir.int<53> : !s32i, #cir.int<54> : !s32i, #cir.int<55> : !s32i, #cir.int<56> : !s32i, #cir.int<57> : !s32i, #cir.int<58> : !s32i, #cir.int<59> : !s32i, #cir.int<60> : !s32i, #cir.int<61> : !s32i, #cir.int<62> : !s32i, #cir.int<63> : !s32i, #cir.int<64> : !s32i, #cir.int<65> : !s32i, #cir.int<66> : !s32i, #cir.int<67> : !s32i, #cir.int<68> : !s32i, #cir.int<69> : !s32i, #cir.int<70> : !s32i, #cir.int<71> : !s32i, #cir.int<72> : !s32i, #cir.int<73> : !s32i, #cir.int<74> : !s32i, #cir.int<75> : !s32i, #cir.int<76> : !s32i, #cir.int<77> : !s32i, #cir.int<78> : !s32i, #cir.int<79> : !s32i, #cir.int<80> : !s32i, #cir.int<81> : !s32i, #cir.int<82> : !s32i, #cir.int<83> : !s32i, #cir.int<84> : !s32i, #cir.int<85> : !s32i, #cir.int<86> : !s32i, #cir.int<87> : !s32i, #cir.int<88> : !s32i, #cir.int<89> : !s32i, #cir.int<90> : !s32i, #cir.int<91> : !s32i, #cir.int<92> : !s32i, #cir.int<93> : !s32i, #cir.int<94> : !s32i, #cir.int<95> : !s32i] : !cir.vector<64 x !cir.int> // LLVM-LABEL: test_kshiftri_mask64 // LLVM: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[RES:%.*]] = shufflevector <64 x i1> [[VAL]], <64 x i1> zeroinitializer, <64 x i32> // OGCG-LABEL: test_kshiftri_mask64 // OGCG: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // OGCG: [[RES:%.*]] = shufflevector <64 x i1> [[VAL]], <64 x i1> zeroinitializer, <64 x i32> return _kshiftri_mask64(A, 32); } __mmask32 test_kshiftli_mask32_out_of_range(__mmask32 A) { // CIR-LABEL: test_kshiftli_mask32_out_of_range // CIR: [[VAL:%.*]] = cir.const #cir.int<0> : !u32i // CIR: cir.store [[VAL]], {{%.*}} : !u32i, !cir.ptr // CIR: [[RES:%.*]] = cir.load {{%.*}} : !cir.ptr, !u32i // CIR: cir.return [[RES]] : !u32i // LLVM-LABEL: test_kshiftli_mask32_out_of_range // LLVM: store i32 0, ptr [[VAL:%.*]], align 4 // LLVM: [[RES:%.*]] = load i32, ptr [[VAL]], align 4 // LLVM: ret i32 [[RES]] // OGCG-LABEL: test_kshiftli_mask32_out_of_range // OGCG: ret i32 0 return _kshiftli_mask32(A, 33); } __mmask32 test_kshiftri_mask32_out_of_range(__mmask32 A) { // CIR-LABEL: test_kshiftri_mask32_out_of_range // CIR: [[VAL:%.*]] = cir.const #cir.int<0> : !u32i // CIR: cir.store [[VAL]], {{%.*}} : !u32i, !cir.ptr // CIR: [[RES:%.*]] = cir.load {{%.*}} : !cir.ptr, !u32i // CIR: cir.return [[RES]] : !u32i // LLVM-LABEL: test_kshiftri_mask32_out_of_range // LLVM: store i32 0, ptr [[VAL:%.*]], align 4 // LLVM: [[RES:%.*]] = load i32, ptr [[VAL]], align 4 // LLVM: ret i32 [[RES]] // OGCG-LABEL: test_kshiftri_mask32_out_of_range // OGCG: ret i32 0 return _kshiftri_mask32(A, 33); } __mmask32 test_kadd_mask32(__mmask32 A, __mmask32 B) { // CIR-LABEL: _kadd_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.call_llvm_intrinsic "x86.avx512.kadd.d" // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _kadd_mask32 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[RES:%.*]] = call <32 x i1> @llvm.x86.avx512.kadd.d(<32 x i1> [[L]], <32 x i1> [[R]]) // LLVM: bitcast <32 x i1> [[RES]] to i32 // OGCG-LABEL: _kadd_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: call <32 x i1> @llvm.x86.avx512.kadd.d // OGCG: bitcast <32 x i1> {{.*}} to i32 return _kadd_mask32(A, B); } __mmask64 test_kadd_mask64(__mmask64 A, __mmask64 B) { // CIR-LABEL: _kadd_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.call_llvm_intrinsic "x86.avx512.kadd.q" // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _kadd_mask64 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[RES:%.*]] = call <64 x i1> @llvm.x86.avx512.kadd.q(<64 x i1> [[L]], <64 x i1> [[R]]) // LLVM: bitcast <64 x i1> [[RES]] to i64 // OGCG-LABEL: _kadd_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: call <64 x i1> @llvm.x86.avx512.kadd.q // OGCG: bitcast <64 x i1> {{.*}} to i64 return _kadd_mask64(A, B); } __mmask32 test_kand_mask32(__mmask32 A, __mmask32 B) { // CIR-LABEL: _kand_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _kand_mask32 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[RES:%.*]] = and <32 x i1> [[L]], [[R]] // LLVM: bitcast <32 x i1> [[RES]] to i32 // OGCG-LABEL: _kand_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: and <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return _kand_mask32(A, B); } __mmask64 test_kand_mask64(__mmask64 A, __mmask64 B) { // CIR-LABEL: _kand_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _kand_mask64 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[RES:%.*]] = and <64 x i1> [[L]], [[R]] // LLVM: bitcast <64 x i1> [[RES]] to i64 // OGCG-LABEL: _kand_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: and <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return _kand_mask64(A, B); } __mmask32 test_kandn_mask32(__mmask32 A, __mmask32 B) { // CIR-LABEL: _kandn_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _kandn_mask32 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: xor <32 x i1> [[L]], splat (i1 true) // LLVM: and <32 x i1> // LLVM: bitcast <32 x i1> {{.*}} to i32 // OGCG-LABEL: _kandn_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: xor <32 x i1> // OGCG: and <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return _kandn_mask32(A, B); } __mmask64 test_kandn_mask64(__mmask64 A, __mmask64 B) { // CIR-LABEL: _kandn_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _kandn_mask64 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: xor <64 x i1> [[L]], splat (i1 true) // LLVM: and <64 x i1> // LLVM: bitcast <64 x i1> {{.*}} to i64 // OGCG-LABEL: _kandn_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: xor <64 x i1> // OGCG: and <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return _kandn_mask64(A, B); } __mmask32 test_kor_mask32(__mmask32 A, __mmask32 B) { // CIR-LABEL: _kor_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.binop(or, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _kor_mask32 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: or <32 x i1> [[L]], [[R]] // LLVM: bitcast <32 x i1> {{.*}} to i32 // OGCG-LABEL: _kor_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: or <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return _kor_mask32(A, B); } __mmask64 test_kor_mask64(__mmask64 A, __mmask64 B) { // CIR-LABEL: _kor_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.binop(or, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _kor_mask64 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: or <64 x i1> [[L]], [[R]] // LLVM: bitcast <64 x i1> {{.*}} to i64 // OGCG-LABEL: _kor_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: or <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return _kor_mask64(A, B); } __mmask32 test_kxor_mask32(__mmask32 A, __mmask32 B) { // CIR-LABEL: _kxor_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _kxor_mask32 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: xor <32 x i1> [[L]], [[R]] // LLVM: bitcast <32 x i1> {{.*}} to i32 // OGCG-LABEL: _kxor_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: xor <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return _kxor_mask32(A, B); } __mmask64 test_kxor_mask64(__mmask64 A, __mmask64 B) { // CIR-LABEL: _kxor_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _kxor_mask64 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: xor <64 x i1> [[L]], [[R]] // LLVM: bitcast <64 x i1> {{.*}} to i64 // OGCG-LABEL: _kxor_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: xor <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return _kxor_mask64(A, B); } __mmask32 test_kxnor_mask32(__mmask32 A, __mmask32 B) { // CIR-LABEL: _kxnor_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _kxnor_mask32 // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1> // LLVM: [[NOT:%.*]] = xor <32 x i1> [[L]], splat (i1 true) // LLVM: [[RES:%.*]] = xor <32 x i1> [[NOT]], [[R]] // LLVM: bitcast <32 x i1> [[RES]] to i32 // OGCG-LABEL: _kxnor_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: xor <32 x i1> // OGCG: xor <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return _kxnor_mask32(A, B); } __mmask64 test_kxnor_mask64(__mmask64 A, __mmask64 B) { // CIR-LABEL: _kxnor_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _kxnor_mask64 // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1> // LLVM: [[NOT:%.*]] = xor <64 x i1> [[L]], splat (i1 true) // LLVM: [[RES:%.*]] = xor <64 x i1> [[NOT]], [[R]] // LLVM: bitcast <64 x i1> [[RES]] to i64 // OGCG-LABEL: _kxnor_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: xor <64 x i1> // OGCG: xor <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return _kxnor_mask64(A, B); } __mmask32 test_knot_mask32(__mmask32 A) { // CIR-LABEL: _knot_mask32 // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: _knot_mask32 // LLVM: bitcast i32 %{{.*}} to <32 x i1> // LLVM: xor <32 x i1> // LLVM: bitcast <32 x i1> {{.*}} to i32 // OGCG-LABEL: _knot_mask32 // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: xor <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return _knot_mask32(A); } __mmask64 test_knot_mask64(__mmask64 A) { // CIR-LABEL: _knot_mask64 // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: _knot_mask64 // LLVM: bitcast i64 %{{.*}} to <64 x i1> // LLVM: xor <64 x i1> // LLVM: bitcast <64 x i1> {{.*}} to i64 // OGCG-LABEL: _knot_mask64 // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: xor <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return _knot_mask64(A); } // Multiple user-level mask helpers inline to this same kmov builtin. // CIR does not implement any special lowering for those helpers. // // Therefore, testing the builtin (__builtin_ia32_kmov*) directly is // sufficient to cover the CIR lowering behavior. Testing each helper // individually would add no new CIR paths. __mmask32 test_kmov_d(__mmask32 A) { // CIR-LABEL: test_kmov_d // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int> -> !u32i // LLVM-LABEL: test_kmov_d // LLVM: bitcast i32 %{{.*}} to <32 x i1> // LLVM: bitcast <32 x i1> {{.*}} to i32 // OGCG-LABEL: test_kmov_d // OGCG: bitcast i32 %{{.*}} to <32 x i1> // OGCG: bitcast <32 x i1> {{.*}} to i32 return __builtin_ia32_kmovd(A); } // Multiple user-level mask helpers inline to this same kmov builtin. // CIR does not implement any special lowering for those helpers. // // Therefore, testing the builtin (__builtin_ia32_kmov*) directly is // sufficient to cover the CIR lowering behavior. Testing each helper // individually would add no new CIR paths. __mmask64 test_kmov_q(__mmask64 A) { // CIR-LABEL: test_kmov_q // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int> // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int> -> !u64i // LLVM-LABEL: test_kmov_q // LLVM: bitcast i64 %{{.*}} to <64 x i1> // LLVM: bitcast <64 x i1> {{.*}} to i64 // OGCG-LABEL: test_kmov_q // OGCG: bitcast i64 %{{.*}} to <64 x i1> // OGCG: bitcast <64 x i1> {{.*}} to i64 return __builtin_ia32_kmovq(A); }