1; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s 2 3; CHECK-LABEL: test1 4; CHECK: vpcmpeqb {{.*%k[0-7]}} 5; CHECK: vmovdqu8 {{.*}}%k1 6; CHECK: ret 7define <64 x i8> @test1(<64 x i8> %x, <64 x i8> %y) nounwind { 8 %mask = icmp eq <64 x i8> %x, %y 9 %max = select <64 x i1> %mask, <64 x i8> %x, <64 x i8> %y 10 ret <64 x i8> %max 11} 12 13; CHECK-LABEL: test2 14; CHECK: vpcmpgtb {{.*%k[0-7]}} 15; CHECK: vmovdqu8 {{.*}}%k1 16; CHECK: ret 17define <64 x i8> @test2(<64 x i8> %x, <64 x i8> %y, <64 x i8> %x1) nounwind { 18 %mask = icmp sgt <64 x i8> %x, %y 19 %max = select <64 x i1> %mask, <64 x i8> %x1, <64 x i8> %y 20 ret <64 x i8> %max 21} 22 23; CHECK-LABEL: @test3 24; CHECK: vpcmplew {{.*%k[0-7]}} 25; CHECK: vmovdqu16 26; CHECK: ret 27define <32 x i16> @test3(<32 x i16> %x, <32 x i16> %y, <32 x i16> %x1) nounwind { 28 %mask = icmp sge <32 x i16> %x, %y 29 %max = select <32 x i1> %mask, <32 x i16> %x1, <32 x i16> %y 30 ret <32 x i16> %max 31} 32 33; CHECK-LABEL: test4 34; CHECK: vpcmpnleub {{.*%k[0-7]}} 35; CHECK: vmovdqu8 {{.*}}%k1 36; CHECK: ret 37define <64 x i8> @test4(<64 x i8> %x, <64 x i8> %y, <64 x i8> %x1) nounwind { 38 %mask = icmp ugt <64 x i8> %x, %y 39 %max = select <64 x i1> %mask, <64 x i8> %x1, <64 x i8> %y 40 ret <64 x i8> %max 41} 42 43; CHECK-LABEL: test5 44; CHECK: vpcmpeqw (%rdi){{.*%k[0-7]}} 45; CHECK: vmovdqu16 46; CHECK: ret 47define <32 x i16> @test5(<32 x i16> %x, <32 x i16> %x1, <32 x i16>* %yp) nounwind { 48 %y = load <32 x i16>, <32 x i16>* %yp, align 4 49 %mask = icmp eq <32 x i16> %x, %y 50 %max = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %x1 51 ret <32 x i16> %max 52} 53 54; CHECK-LABEL: @test6 55; CHECK: vpcmpgtw (%rdi){{.*%k[0-7]}} 56; CHECK: vmovdqu16 57; CHECK: ret 58define <32 x i16> @test6(<32 x i16> %x, <32 x i16> %x1, <32 x i16>* %y.ptr) nounwind { 59 %y = load <32 x i16>, <32 x i16>* %y.ptr, align 4 60 %mask = icmp sgt <32 x i16> %x, %y 61 %max = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %x1 62 ret <32 x i16> %max 63} 64 65; CHECK-LABEL: @test7 66; CHECK: vpcmplew (%rdi){{.*%k[0-7]}} 67; CHECK: vmovdqu16 68; CHECK: ret 69define <32 x i16> @test7(<32 x i16> %x, <32 x i16> %x1, <32 x i16>* %y.ptr) nounwind { 70 %y = load <32 x i16>, <32 x i16>* %y.ptr, align 4 71 %mask = icmp sle <32 x i16> %x, %y 72 %max = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %x1 73 ret <32 x i16> %max 74} 75 76; CHECK-LABEL: @test8 77; CHECK: vpcmpleuw (%rdi){{.*%k[0-7]}} 78; CHECK: vmovdqu16 79; CHECK: ret 80define <32 x i16> @test8(<32 x i16> %x, <32 x i16> %x1, <32 x i16>* %y.ptr) nounwind { 81 %y = load <32 x i16>, <32 x i16>* %y.ptr, align 4 82 %mask = icmp ule <32 x i16> %x, %y 83 %max = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %x1 84 ret <32 x i16> %max 85} 86 87; CHECK-LABEL: @test9 88; CHECK: vpcmpeqw %zmm{{.*{%k[1-7]}}} 89; CHECK: vmovdqu16 90; CHECK: ret 91define <32 x i16> @test9(<32 x i16> %x, <32 x i16> %y, <32 x i16> %x1, <32 x i16> %y1) nounwind { 92 %mask1 = icmp eq <32 x i16> %x1, %y1 93 %mask0 = icmp eq <32 x i16> %x, %y 94 %mask = select <32 x i1> %mask0, <32 x i1> %mask1, <32 x i1> zeroinitializer 95 %max = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %y 96 ret <32 x i16> %max 97} 98 99; CHECK-LABEL: @test10 100; CHECK: vpcmpleb %zmm{{.*{%k[1-7]}}} 101; CHECK: vmovdqu8 102; CHECK: ret 103define <64 x i8> @test10(<64 x i8> %x, <64 x i8> %y, <64 x i8> %x1, <64 x i8> %y1) nounwind { 104 %mask1 = icmp sge <64 x i8> %x1, %y1 105 %mask0 = icmp sle <64 x i8> %x, %y 106 %mask = select <64 x i1> %mask0, <64 x i1> %mask1, <64 x i1> zeroinitializer 107 %max = select <64 x i1> %mask, <64 x i8> %x, <64 x i8> %x1 108 ret <64 x i8> %max 109} 110 111; CHECK-LABEL: @test11 112; CHECK: vpcmpgtb (%rdi){{.*{%k[1-7]}}} 113; CHECK: vmovdqu8 114; CHECK: ret 115define <64 x i8> @test11(<64 x i8> %x, <64 x i8>* %y.ptr, <64 x i8> %x1, <64 x i8> %y1) nounwind { 116 %mask1 = icmp sgt <64 x i8> %x1, %y1 117 %y = load <64 x i8>, <64 x i8>* %y.ptr, align 4 118 %mask0 = icmp sgt <64 x i8> %x, %y 119 %mask = select <64 x i1> %mask0, <64 x i1> %mask1, <64 x i1> zeroinitializer 120 %max = select <64 x i1> %mask, <64 x i8> %x, <64 x i8> %x1 121 ret <64 x i8> %max 122} 123 124; CHECK-LABEL: @test12 125; CHECK: vpcmpleuw (%rdi){{.*{%k[1-7]}}} 126; CHECK: vmovdqu16 127; CHECK: ret 128define <32 x i16> @test12(<32 x i16> %x, <32 x i16>* %y.ptr, <32 x i16> %x1, <32 x i16> %y1) nounwind { 129 %mask1 = icmp sge <32 x i16> %x1, %y1 130 %y = load <32 x i16>, <32 x i16>* %y.ptr, align 4 131 %mask0 = icmp ule <32 x i16> %x, %y 132 %mask = select <32 x i1> %mask0, <32 x i1> %mask1, <32 x i1> zeroinitializer 133 %max = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %x1 134 ret <32 x i16> %max 135} 136