brintos

brintos / llvm-project-archived public Read only

0
0
Text · 26.3 KiB · 4863ba0 Raw
468 lines · c
1// 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 -Werror2// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s3// 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 -Werror4// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s5 6// 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 -Werror7// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s8// 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 -Werror9// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s10 11// 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=OGCG12// 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=OGCG13 14// This test mimics clang/test/CodeGen/X86/avx512bw-builtins.c, which eventually15// CIR shall be able to support fully.16 17#include <immintrin.h>18 19__mmask32 test_kshiftli_mask32(__mmask32 A) {20  // CIR-LABEL: test_kshiftli_mask3221  // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>22  // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<32 x !cir.int<u, 1>>23  // CIR: %{{.*}} = cir.vec.shuffle([[SHIFT]], [[VAL]] : !cir.vector<32 x !cir.int<u, 1>>) [#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<u, 1>>24 25  // LLVM-LABEL: test_kshiftli_mask3226  // LLVM: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>27  // LLVM: [[RES:%.*]] = shufflevector <32 x i1> zeroinitializer, <32 x i1> [[VAL]], <32 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32>28 29  // OGCG-LABEL: test_kshiftli_mask3230  // OGCG: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>31  // OGCG: [[RES:%.*]] = shufflevector <32 x i1> zeroinitializer, <32 x i1> [[VAL]], <32 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32>32  return _kshiftli_mask32(A, 31);33}34 35__mmask32 test_kshiftri_mask32(__mmask32 A) {36  // CIR-LABEL: test_kshiftri_mask3237  // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>38  // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<32 x !cir.int<u, 1>>39  // CIR: %{{.*}} = cir.vec.shuffle([[VAL]], [[SHIFT]] : !cir.vector<32 x !cir.int<u, 1>>) [#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<u, 1>>40 41  // LLVM-LABEL: test_kshiftri_mask3242  // LLVM: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>43  // LLVM: [[RES:%.*]] = shufflevector <32 x i1> [[VAL]], <32 x i1> zeroinitializer, <32 x i32> <i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62>44 45  // OGCG-LABEL: test_kshiftri_mask3246  // OGCG: [[VAL:%.*]] = bitcast i32 %{{.*}} to <32 x i1>47  // OGCG: [[RES:%.*]] = shufflevector <32 x i1> [[VAL]], <32 x i1> zeroinitializer, <32 x i32> <i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62>48  return _kshiftri_mask32(A, 31);49}50 51__mmask64 test_kshiftli_mask64(__mmask64 A) {52  // CIR-LABEL: test_kshiftli_mask6453  // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>54  // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<64 x !cir.int<u, 1>>55  // CIR: %{{.*}} = cir.vec.shuffle([[SHIFT]], [[VAL]] : !cir.vector<64 x !cir.int<u, 1>>) [#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<u, 1>>56 57  // LLVM-LABEL: test_kshiftli_mask6458  // LLVM: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>59  // LLVM: [[RES:%.*]] = shufflevector <64 x i1> zeroinitializer, <64 x i1> [[VAL]], <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>60 61  // OGCG-LABEL: test_kshiftli_mask6462  // OGCG: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>63  // OGCG: [[RES:%.*]] = shufflevector <64 x i1> zeroinitializer, <64 x i1> [[VAL]], <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>64  return _kshiftli_mask64(A, 32);65}66 67__mmask64 test_kshiftri_mask64(__mmask64 A) {68  // CIR-LABEL: test_kshiftri_mask6469  // CIR: [[VAL:%.*]] = cir.cast bitcast %{{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>70  // CIR: [[SHIFT:%.*]] = cir.const #cir.zero : !cir.vector<64 x !cir.int<u, 1>>71  // CIR: %{{.*}} = cir.vec.shuffle([[VAL]], [[SHIFT]] : !cir.vector<64 x !cir.int<u, 1>>) [#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<u, 1>>72 73  // LLVM-LABEL: test_kshiftri_mask6474  // LLVM: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>75  // LLVM: [[RES:%.*]] = shufflevector <64 x i1> [[VAL]], <64 x i1> zeroinitializer, <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>76 77  // OGCG-LABEL: test_kshiftri_mask6478  // OGCG: [[VAL:%.*]] = bitcast i64 %{{.*}} to <64 x i1>79  // OGCG: [[RES:%.*]] = shufflevector <64 x i1> [[VAL]], <64 x i1> zeroinitializer, <64 x i32> <i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 58, i32 59, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70, i32 71, i32 72, i32 73, i32 74, i32 75, i32 76, i32 77, i32 78, i32 79, i32 80, i32 81, i32 82, i32 83, i32 84, i32 85, i32 86, i32 87, i32 88, i32 89, i32 90, i32 91, i32 92, i32 93, i32 94, i32 95>80  return _kshiftri_mask64(A, 32);81}82 83__mmask32 test_kshiftli_mask32_out_of_range(__mmask32 A) {84  // CIR-LABEL: test_kshiftli_mask32_out_of_range85  // CIR: [[VAL:%.*]] = cir.const #cir.int<0> : !u32i86  // CIR: cir.store [[VAL]], {{%.*}} : !u32i, !cir.ptr<!u32i>87  // CIR: [[RES:%.*]] = cir.load {{%.*}} : !cir.ptr<!u32i>, !u32i88  // CIR: cir.return [[RES]] : !u32i89 90  // LLVM-LABEL: test_kshiftli_mask32_out_of_range91  // LLVM: store i32 0, ptr [[VAL:%.*]], align 492  // LLVM: [[RES:%.*]] = load i32, ptr [[VAL]], align 493  // LLVM: ret i32 [[RES]]94 95  // OGCG-LABEL: test_kshiftli_mask32_out_of_range96  // OGCG: ret i32 097 98  return _kshiftli_mask32(A, 33);99}100 101__mmask32 test_kshiftri_mask32_out_of_range(__mmask32 A) {102  // CIR-LABEL: test_kshiftri_mask32_out_of_range103  // CIR: [[VAL:%.*]] = cir.const #cir.int<0> : !u32i104  // CIR: cir.store [[VAL]], {{%.*}} : !u32i, !cir.ptr<!u32i>105  // CIR: [[RES:%.*]] = cir.load {{%.*}} : !cir.ptr<!u32i>, !u32i106  // CIR: cir.return [[RES]] : !u32i107 108  // LLVM-LABEL: test_kshiftri_mask32_out_of_range109  // LLVM: store i32 0, ptr [[VAL:%.*]], align 4110  // LLVM: [[RES:%.*]] = load i32, ptr [[VAL]], align 4111  // LLVM: ret i32 [[RES]]112 113  // OGCG-LABEL: test_kshiftri_mask32_out_of_range114  // OGCG: ret i32 0115 116  return _kshiftri_mask32(A, 33);117}118 119 120__mmask32 test_kadd_mask32(__mmask32 A, __mmask32 B) {121  // CIR-LABEL: _kadd_mask32122  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>123  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>124  // CIR: cir.call_llvm_intrinsic "x86.avx512.kadd.d"125  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i126 127  // LLVM-LABEL: _kadd_mask32128  // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>129  // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>130  // LLVM: [[RES:%.*]] = call <32 x i1> @llvm.x86.avx512.kadd.d(<32 x i1> [[L]], <32 x i1> [[R]])131  // LLVM: bitcast <32 x i1> [[RES]] to i32132 133  // OGCG-LABEL: _kadd_mask32134  // OGCG: bitcast i32 %{{.*}} to <32 x i1>135  // OGCG: bitcast i32 %{{.*}} to <32 x i1>136  // OGCG: call <32 x i1> @llvm.x86.avx512.kadd.d137  // OGCG: bitcast <32 x i1> {{.*}} to i32138  return _kadd_mask32(A, B);139}140 141__mmask64 test_kadd_mask64(__mmask64 A, __mmask64 B) {142  // CIR-LABEL: _kadd_mask64143  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>144  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>145  // CIR: cir.call_llvm_intrinsic "x86.avx512.kadd.q"146  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i147 148  // LLVM-LABEL: _kadd_mask64149  // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>150  // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>151  // LLVM: [[RES:%.*]] = call <64 x i1> @llvm.x86.avx512.kadd.q(<64 x i1> [[L]], <64 x i1> [[R]])152  // LLVM: bitcast <64 x i1> [[RES]] to i64153 154  // OGCG-LABEL: _kadd_mask64155  // OGCG: bitcast i64 %{{.*}} to <64 x i1>156  // OGCG: bitcast i64 %{{.*}} to <64 x i1>157  // OGCG: call <64 x i1> @llvm.x86.avx512.kadd.q158  // OGCG: bitcast <64 x i1> {{.*}} to i64159  return _kadd_mask64(A, B);160}161 162__mmask32 test_kand_mask32(__mmask32 A, __mmask32 B) {163  // CIR-LABEL: _kand_mask32164  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>165  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>166  // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>167  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i168 169  // LLVM-LABEL: _kand_mask32170  // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>171  // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>172  // LLVM: [[RES:%.*]] = and <32 x i1> [[L]], [[R]]173  // LLVM: bitcast <32 x i1> [[RES]] to i32174 175  // OGCG-LABEL: _kand_mask32176  // OGCG: bitcast i32 %{{.*}} to <32 x i1>177  // OGCG: bitcast i32 %{{.*}} to <32 x i1>178  // OGCG: and <32 x i1>179  // OGCG: bitcast <32 x i1> {{.*}} to i32180  return _kand_mask32(A, B);181}182 183__mmask64 test_kand_mask64(__mmask64 A, __mmask64 B) {184  // CIR-LABEL: _kand_mask64185  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>186  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>187  // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>188  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i189 190  // LLVM-LABEL: _kand_mask64191  // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>192  // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>193  // LLVM: [[RES:%.*]] = and <64 x i1> [[L]], [[R]]194  // LLVM: bitcast <64 x i1> [[RES]] to i64195 196  // OGCG-LABEL: _kand_mask64197  // OGCG: bitcast i64 %{{.*}} to <64 x i1>198  // OGCG: bitcast i64 %{{.*}} to <64 x i1>199  // OGCG: and <64 x i1>200  // OGCG: bitcast <64 x i1> {{.*}} to i64201  return _kand_mask64(A, B);202}203 204__mmask32 test_kandn_mask32(__mmask32 A, __mmask32 B) {205  // CIR-LABEL: _kandn_mask32206  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>207  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>208  // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>209  // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>210  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i211 212  // LLVM-LABEL: _kandn_mask32213  // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>214  // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>215  // LLVM: xor <32 x i1> [[L]], splat (i1 true)216  // LLVM: and <32 x i1>217  // LLVM: bitcast <32 x i1> {{.*}} to i32218 219  // OGCG-LABEL: _kandn_mask32220  // OGCG: bitcast i32 %{{.*}} to <32 x i1>221  // OGCG: bitcast i32 %{{.*}} to <32 x i1>222  // OGCG: xor <32 x i1>223  // OGCG: and <32 x i1>224  // OGCG: bitcast <32 x i1> {{.*}} to i32225  return _kandn_mask32(A, B);226}227 228__mmask64 test_kandn_mask64(__mmask64 A, __mmask64 B) {229  // CIR-LABEL: _kandn_mask64230  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>231  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>232  // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>233  // CIR: cir.binop(and, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>234  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i235 236  // LLVM-LABEL: _kandn_mask64237  // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>238  // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>239  // LLVM: xor <64 x i1> [[L]], splat (i1 true)240  // LLVM: and <64 x i1>241  // LLVM: bitcast <64 x i1> {{.*}} to i64242 243  // OGCG-LABEL: _kandn_mask64244  // OGCG: bitcast i64 %{{.*}} to <64 x i1>245  // OGCG: bitcast i64 %{{.*}} to <64 x i1>246  // OGCG: xor <64 x i1>247  // OGCG: and <64 x i1>248  // OGCG: bitcast <64 x i1> {{.*}} to i64249  return _kandn_mask64(A, B);250}251 252__mmask32 test_kor_mask32(__mmask32 A, __mmask32 B) {253  // CIR-LABEL: _kor_mask32254  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>255  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>256  // CIR: cir.binop(or, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>257  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i258 259  // LLVM-LABEL: _kor_mask32260  // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>261  // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>262  // LLVM: or <32 x i1> [[L]], [[R]]263  // LLVM: bitcast <32 x i1> {{.*}} to i32264 265  // OGCG-LABEL: _kor_mask32266  // OGCG: bitcast i32 %{{.*}} to <32 x i1>267  // OGCG: bitcast i32 %{{.*}} to <32 x i1>268  // OGCG: or <32 x i1>269  // OGCG: bitcast <32 x i1> {{.*}} to i32270  return _kor_mask32(A, B);271}272 273__mmask64 test_kor_mask64(__mmask64 A, __mmask64 B) {274  // CIR-LABEL: _kor_mask64275  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>276  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>277  // CIR: cir.binop(or, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>278  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i279 280  // LLVM-LABEL: _kor_mask64281  // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>282  // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>283  // LLVM: or <64 x i1> [[L]], [[R]]284  // LLVM: bitcast <64 x i1> {{.*}} to i64285 286  // OGCG-LABEL: _kor_mask64287  // OGCG: bitcast i64 %{{.*}} to <64 x i1>288  // OGCG: bitcast i64 %{{.*}} to <64 x i1>289  // OGCG: or <64 x i1>290  // OGCG: bitcast <64 x i1> {{.*}} to i64291  return _kor_mask64(A, B);292}293 294__mmask32 test_kxor_mask32(__mmask32 A, __mmask32 B) {295  // CIR-LABEL: _kxor_mask32296  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>297  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>298  // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>299  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i300 301  // LLVM-LABEL: _kxor_mask32302  // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>303  // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>304  // LLVM: xor <32 x i1> [[L]], [[R]]305  // LLVM: bitcast <32 x i1> {{.*}} to i32306 307  // OGCG-LABEL: _kxor_mask32308  // OGCG: bitcast i32 %{{.*}} to <32 x i1>309  // OGCG: bitcast i32 %{{.*}} to <32 x i1>310  // OGCG: xor <32 x i1>311  // OGCG: bitcast <32 x i1> {{.*}} to i32312  return _kxor_mask32(A, B);313}314 315__mmask64 test_kxor_mask64(__mmask64 A, __mmask64 B) {316  // CIR-LABEL: _kxor_mask64317  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>318  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>319  // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>320  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i321 322  // LLVM-LABEL: _kxor_mask64323  // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>324  // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>325  // LLVM: xor <64 x i1> [[L]], [[R]]326  // LLVM: bitcast <64 x i1> {{.*}} to i64327 328  // OGCG-LABEL: _kxor_mask64329  // OGCG: bitcast i64 %{{.*}} to <64 x i1>330  // OGCG: bitcast i64 %{{.*}} to <64 x i1>331  // OGCG: xor <64 x i1>332  // OGCG: bitcast <64 x i1> {{.*}} to i64333  return _kxor_mask64(A, B);334}335 336__mmask32 test_kxnor_mask32(__mmask32 A, __mmask32 B) {337  // CIR-LABEL: _kxnor_mask32338  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>339  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>340  // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>341  // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>342  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i343 344  // LLVM-LABEL: _kxnor_mask32345  // LLVM: [[L:%.*]] = bitcast i32 %{{.*}} to <32 x i1>346  // LLVM: [[R:%.*]] = bitcast i32 %{{.*}} to <32 x i1>347  // LLVM: [[NOT:%.*]] = xor <32 x i1> [[L]], splat (i1 true)348  // LLVM: [[RES:%.*]] = xor <32 x i1> [[NOT]], [[R]]349  // LLVM: bitcast <32 x i1> [[RES]] to i32350 351  // OGCG-LABEL: _kxnor_mask32352  // OGCG: bitcast i32 %{{.*}} to <32 x i1>353  // OGCG: bitcast i32 %{{.*}} to <32 x i1>354  // OGCG: xor <32 x i1>355  // OGCG: xor <32 x i1>356  // OGCG: bitcast <32 x i1> {{.*}} to i32357 358  return _kxnor_mask32(A, B);359}360 361__mmask64 test_kxnor_mask64(__mmask64 A, __mmask64 B) {362  // CIR-LABEL: _kxnor_mask64363  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>364  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>365  // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>366  // CIR: cir.binop(xor, {{.*}}, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>367  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i368 369  // LLVM-LABEL: _kxnor_mask64370  // LLVM: [[L:%.*]] = bitcast i64 %{{.*}} to <64 x i1>371  // LLVM: [[R:%.*]] = bitcast i64 %{{.*}} to <64 x i1>372  // LLVM: [[NOT:%.*]] = xor <64 x i1> [[L]], splat (i1 true)373  // LLVM: [[RES:%.*]] = xor <64 x i1> [[NOT]], [[R]]374  // LLVM: bitcast <64 x i1> [[RES]] to i64375 376  // OGCG-LABEL: _kxnor_mask64377  // OGCG: bitcast i64 %{{.*}} to <64 x i1>378  // OGCG: bitcast i64 %{{.*}} to <64 x i1>379  // OGCG: xor <64 x i1>380  // OGCG: xor <64 x i1>381  // OGCG: bitcast <64 x i1> {{.*}} to i64382 383  return _kxnor_mask64(A, B);384}385 386 387__mmask32 test_knot_mask32(__mmask32 A) {388  // CIR-LABEL: _knot_mask32389  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>390  // CIR: cir.unary(not, {{.*}}) : !cir.vector<32 x !cir.int<u, 1>>391  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i392 393  // LLVM-LABEL: _knot_mask32394  // LLVM: bitcast i32 %{{.*}} to <32 x i1>395  // LLVM: xor <32 x i1>396  // LLVM: bitcast <32 x i1> {{.*}} to i32397 398  // OGCG-LABEL: _knot_mask32399  // OGCG: bitcast i32 %{{.*}} to <32 x i1>400  // OGCG: xor <32 x i1>401  // OGCG: bitcast <32 x i1> {{.*}} to i32402  return _knot_mask32(A);403}404 405__mmask64 test_knot_mask64(__mmask64 A) {406  // CIR-LABEL: _knot_mask64407  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>408  // CIR: cir.unary(not, {{.*}}) : !cir.vector<64 x !cir.int<u, 1>>409  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i410 411  // LLVM-LABEL: _knot_mask64412  // LLVM: bitcast i64 %{{.*}} to <64 x i1>413  // LLVM: xor <64 x i1>414  // LLVM: bitcast <64 x i1> {{.*}} to i64415 416  // OGCG-LABEL: _knot_mask64417  // OGCG: bitcast i64 %{{.*}} to <64 x i1>418  // OGCG: xor <64 x i1>419  // OGCG: bitcast <64 x i1> {{.*}} to i64420  return _knot_mask64(A);421}422 423// Multiple user-level mask helpers inline to this same kmov builtin.424// CIR does not implement any special lowering for those helpers.425//426// Therefore, testing the builtin (__builtin_ia32_kmov*) directly is427// sufficient to cover the CIR lowering behavior. Testing each helper428// individually would add no new CIR paths.429 430__mmask32 test_kmov_d(__mmask32 A) {431  // CIR-LABEL: test_kmov_d432  // CIR: cir.cast bitcast {{.*}} : !u32i -> !cir.vector<32 x !cir.int<u, 1>>433  // CIR: cir.cast bitcast {{.*}} : !cir.vector<32 x !cir.int<u, 1>> -> !u32i434 435  // LLVM-LABEL: test_kmov_d436  // LLVM: bitcast i32 %{{.*}} to <32 x i1>437  // LLVM: bitcast <32 x i1> {{.*}} to i32438 439  // OGCG-LABEL: test_kmov_d440  // OGCG: bitcast i32 %{{.*}} to <32 x i1>441  // OGCG: bitcast <32 x i1> {{.*}} to i32442 443  return __builtin_ia32_kmovd(A);444}445 446// Multiple user-level mask helpers inline to this same kmov builtin.447// CIR does not implement any special lowering for those helpers.448//449// Therefore, testing the builtin (__builtin_ia32_kmov*) directly is450// sufficient to cover the CIR lowering behavior. Testing each helper451// individually would add no new CIR paths.452 453__mmask64 test_kmov_q(__mmask64 A) {454  // CIR-LABEL: test_kmov_q455  // CIR: cir.cast bitcast {{.*}} : !u64i -> !cir.vector<64 x !cir.int<u, 1>>456  // CIR: cir.cast bitcast {{.*}} : !cir.vector<64 x !cir.int<u, 1>> -> !u64i457 458  // LLVM-LABEL: test_kmov_q459  // LLVM: bitcast i64 %{{.*}} to <64 x i1>460  // LLVM: bitcast <64 x i1> {{.*}} to i64461 462  // OGCG-LABEL: test_kmov_q463  // OGCG: bitcast i64 %{{.*}} to <64 x i1>464  // OGCG: bitcast <64 x i1> {{.*}} to i64465 466  return __builtin_ia32_kmovq(A);467}468