1; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl | FileCheck %s --check-prefix=KNL 2; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s --check-prefix=SKX 3; RUN: llc < %s -mtriple=i686-apple-darwin -mcpu=knl | FileCheck %s --check-prefix=KNL_X32 4 5; KNL-LABEL: test1 6; KNL: vxorps 7define <16 x i1> @test1() { 8 ret <16 x i1> zeroinitializer 9} 10 11; SKX-LABEL: test2 12; SKX: vpmovb2m 13; SKX: vpmovb2m 14; SKX: kandw 15; SKX: vpmovm2b 16; KNL-LABEL: test2 17; KNL: vpmovsxbd 18; KNL: vpmovsxbd 19; KNL: vpandd 20; KNL: vpmovdb 21define <16 x i1> @test2(<16 x i1>%a, <16 x i1>%b) { 22 %c = and <16 x i1>%a, %b 23 ret <16 x i1> %c 24} 25 26; SKX-LABEL: test3 27; SKX: vpmovw2m 28; SKX: vpmovw2m 29; SKX: kandb 30; SKX: vpmovm2w 31define <8 x i1> @test3(<8 x i1>%a, <8 x i1>%b) { 32 %c = and <8 x i1>%a, %b 33 ret <8 x i1> %c 34} 35 36; SKX-LABEL: test4 37; SKX: vpmovd2m 38; SKX: vpmovd2m 39; SKX: kandw 40; SKX: vpmovm2d 41define <4 x i1> @test4(<4 x i1>%a, <4 x i1>%b) { 42 %c = and <4 x i1>%a, %b 43 ret <4 x i1> %c 44} 45 46; SKX-LABEL: test5 47; SKX: vpcmpgtd 48; SKX: vpmovm2w 49; SKX: call 50; SKX: vpmovzxwd 51declare <8 x i1> @func8xi1(<8 x i1> %a) 52define <8 x i32> @test5(<8 x i32>%a, <8 x i32>%b) { 53 %cmpRes = icmp sgt <8 x i32>%a, %b 54 %resi = call <8 x i1> @func8xi1(<8 x i1> %cmpRes) 55 %res = sext <8 x i1>%resi to <8 x i32> 56 ret <8 x i32> %res 57} 58 59declare <16 x i1> @func16xi1(<16 x i1> %a) 60 61; KNL-LABEL: test6 62; KNL: vpbroadcastd 63; KNL: vpmovdb 64; KNL: call 65; KNL: vpmovzxbd 66; KNL: vpslld $31, %zmm 67; KNL: vpsrad $31, %zmm 68define <16 x i32> @test6(<16 x i32>%a, <16 x i32>%b) { 69 %cmpRes = icmp sgt <16 x i32>%a, %b 70 %resi = call <16 x i1> @func16xi1(<16 x i1> %cmpRes) 71 %res = sext <16 x i1>%resi to <16 x i32> 72 ret <16 x i32> %res 73} 74 75declare <4 x i1> @func4xi1(<4 x i1> %a) 76; SKX-LABEL: test7 77; SKX: vpmovm2d 78; SKX: call 79; SKX: vpslld $31, %xmm 80; SKX: vpsrad $31, %xmm 81 82define <4 x i32> @test7(<4 x i32>%a, <4 x i32>%b) { 83 %cmpRes = icmp sgt <4 x i32>%a, %b 84 %resi = call <4 x i1> @func4xi1(<4 x i1> %cmpRes) 85 %res = sext <4 x i1>%resi to <4 x i32> 86 ret <4 x i32> %res 87} 88 89; SKX-LABEL: test7a 90; SKX: call 91; SKX: vpmovw2m %xmm0, %k0 92; SKX: kandb 93define <8 x i1> @test7a(<8 x i32>%a, <8 x i32>%b) { 94 %cmpRes = icmp sgt <8 x i32>%a, %b 95 %resi = call <8 x i1> @func8xi1(<8 x i1> %cmpRes) 96 %res = and <8 x i1>%resi, <i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false> 97 ret <8 x i1> %res 98} 99 100 101; KNL_X32-LABEL: test8 102; KNL_X32: testb $1, 4(%esp) 103; KNL_X32:jne 104 105; KNL-LABEL: test8 106; KNL: testb $1, %dil 107; KNL:jne 108 109define <16 x i8> @test8(<16 x i8> %a1, <16 x i8> %a2, i1 %cond) { 110 %res = select i1 %cond, <16 x i8> %a1, <16 x i8> %a2 111 ret <16 x i8> %res 112} 113 114; KNL-LABEL: test9 115; KNL: vucomisd 116; KNL: setb 117define i1 @test9(double %a, double %b) { 118 %c = fcmp ugt double %a, %b 119 ret i1 %c 120} 121 122; KNL_X32-LABEL: test10 123; KNL_X32: testb $1, 12(%esp) 124; KNL_X32: cmovnel 125 126; KNL-LABEL: test10 127; KNL: testb $1, %dl 128; KNL: cmovel 129define i32 @test10(i32 %a, i32 %b, i1 %cond) { 130 %c = select i1 %cond, i32 %a, i32 %b 131 ret i32 %c 132} 133 134; KNL-LABEL: test11 135; KNL: cmp 136; KNL: setg 137define i1 @test11(i32 %a, i32 %b) { 138 %c = icmp sgt i32 %a, %b 139 ret i1 %c 140} 141 142; KNL-LABEL: test12 143; KNL: callq _test11 144;; return value in %al 145; KNL: movzbl %al, %ebx 146; KNL: callq _test10 147; KNL: testb $1, %bl 148 149define i32 @test12(i32 %a1, i32 %a2, i32 %b1) { 150 %cond = call i1 @test11(i32 %a1, i32 %b1) 151 %res = call i32 @test10(i32 %a1, i32 %a2, i1 %cond) 152 %res1 = select i1 %cond, i32 %res, i32 0 153 ret i32 %res1 154}