xref: /aosp_15_r20/external/llvm/test/Analysis/CostModel/X86/vselect-cost.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+sse2,-sse4.1 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE2
2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE41
3*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7-avx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX
4*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core-avx2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX2
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; Verify the cost of vector select instructions.
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; SSE41 added blend instructions with an immediate for <2 x double> and
10*9880d681SAndroid Build Coastguard Worker; <4 x float>. Integers of the same size should also use those instructions.
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine <2 x i64> @test_2i64(<2 x i64> %a, <2 x i64> %b) {
13*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_2i64':
14*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
15*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
16*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
17*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
18*9880d681SAndroid Build Coastguard Worker  %sel = select <2 x i1> <i1 true, i1 false>, <2 x i64> %a, <2 x i64> %b
19*9880d681SAndroid Build Coastguard Worker  ret <2 x i64> %sel
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine <2 x double> @test_2double(<2 x double> %a, <2 x double> %b) {
23*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_2double':
24*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
25*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
26*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
27*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <2 x i1>
28*9880d681SAndroid Build Coastguard Worker  %sel = select <2 x i1> <i1 true, i1 false>, <2 x double> %a, <2 x double> %b
29*9880d681SAndroid Build Coastguard Worker  ret <2 x double> %sel
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerdefine <4 x i32> @test_4i32(<4 x i32> %a, <4 x i32> %b) {
33*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_4i32':
34*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
35*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
36*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
37*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
38*9880d681SAndroid Build Coastguard Worker  %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x i32> %a, <4 x i32> %b
39*9880d681SAndroid Build Coastguard Worker  ret <4 x i32> %sel
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @test_4float(<4 x float> %a, <4 x float> %b) {
43*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_4float':
44*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
45*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
46*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
47*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
48*9880d681SAndroid Build Coastguard Worker  %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 true>, <4 x float> %a, <4 x float> %b
49*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %sel
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerdefine <16 x i8> @test_16i8(<16 x i8> %a, <16 x i8> %b) {
53*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_16i8':
54*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 1 for instruction:   %sel = select <16 x i1>
55*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 1 for instruction:   %sel = select <16 x i1>
56*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <16 x i1>
57*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <16 x i1>
58*9880d681SAndroid Build Coastguard Worker  %sel = select <16 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <16 x i8> %a, <16 x i8> %b
59*9880d681SAndroid Build Coastguard Worker  ret <16 x i8> %sel
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker; AVX added blend instructions with an immediate for <4 x double> and
63*9880d681SAndroid Build Coastguard Worker; <8 x float>. Integers of the same size should also use those instructions.
64*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test_4i64(<4 x i64> %a, <4 x i64> %b) {
65*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_4i64':
66*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 2 for instruction:   %sel = select <4 x i1>
67*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 2 for instruction:   %sel = select <4 x i1>
68*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
69*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
70*9880d681SAndroid Build Coastguard Worker  %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i64> %a, <4 x i64> %b
71*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %sel
72*9880d681SAndroid Build Coastguard Worker}
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Workerdefine <4 x double> @test_4double(<4 x double> %a, <4 x double> %b) {
75*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_4double':
76*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 2 for instruction:   %sel = select <4 x i1>
77*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 2 for instruction:   %sel = select <4 x i1>
78*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
79*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <4 x i1>
80*9880d681SAndroid Build Coastguard Worker  %sel = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x double> %a, <4 x double> %b
81*9880d681SAndroid Build Coastguard Worker  ret <4 x double> %sel
82*9880d681SAndroid Build Coastguard Worker}
83*9880d681SAndroid Build Coastguard Worker
84*9880d681SAndroid Build Coastguard Workerdefine <8 x i32> @test_8i32(<8 x i32> %a, <8 x i32> %b) {
85*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_8i32':
86*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 2 for instruction:   %sel = select <8 x i1>
87*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 2 for instruction:   %sel = select <8 x i1>
88*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <8 x i1>
89*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <8 x i1>
90*9880d681SAndroid Build Coastguard Worker  %sel = select <8 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 false>, <8 x i32> %a, <8 x i32> %b
91*9880d681SAndroid Build Coastguard Worker  ret <8 x i32> %sel
92*9880d681SAndroid Build Coastguard Worker}
93*9880d681SAndroid Build Coastguard Worker
94*9880d681SAndroid Build Coastguard Workerdefine <8 x float> @test_8float(<8 x float> %a, <8 x float> %b) {
95*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_8float':
96*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 2 for instruction:   %sel = select <8 x i1>
97*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 2 for instruction:   %sel = select <8 x i1>
98*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <8 x i1>
99*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <8 x i1>
100*9880d681SAndroid Build Coastguard Worker  %sel = select <8 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <8 x float> %a, <8 x float> %b
101*9880d681SAndroid Build Coastguard Worker  ret <8 x float> %sel
102*9880d681SAndroid Build Coastguard Worker}
103*9880d681SAndroid Build Coastguard Worker
104*9880d681SAndroid Build Coastguard Worker; AVX2
105*9880d681SAndroid Build Coastguard Workerdefine <16 x i16> @test_16i16(<16 x i16> %a, <16 x i16> %b) {
106*9880d681SAndroid Build Coastguard Worker; CHECK:Printing analysis 'Cost Model Analysis' for function 'test_16i16':
107*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 2 for instruction:   %sel = select <16 x i1>
108*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 2 for instruction:   %sel = select <16 x i1>
109*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <16 x i1>
110*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <16 x i1>
111*9880d681SAndroid Build Coastguard Worker  %sel = select <16 x i1> <i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false>, <16 x i16> %a, <16 x i16> %b
112*9880d681SAndroid Build Coastguard Worker  ret <16 x i16> %sel
113*9880d681SAndroid Build Coastguard Worker}
114*9880d681SAndroid Build Coastguard Worker
115*9880d681SAndroid Build Coastguard Workerdefine <32 x i8> @test_32i8(<32 x i8> %a, <32 x i8> %b) {
116*9880d681SAndroid Build Coastguard Worker; CHECK: Printing analysis 'Cost Model Analysis' for function 'test_32i8':
117*9880d681SAndroid Build Coastguard Worker; SSE2: Cost Model: {{.*}} 2 for instruction:   %sel = select <32 x i1>
118*9880d681SAndroid Build Coastguard Worker; SSE41: Cost Model: {{.*}} 2 for instruction:   %sel = select <32 x i1>
119*9880d681SAndroid Build Coastguard Worker; AVX: Cost Model: {{.*}} 1 for instruction:   %sel = select <32 x i1>
120*9880d681SAndroid Build Coastguard Worker; AVX2: Cost Model: {{.*}} 1 for instruction:   %sel = select <32 x i1>
121*9880d681SAndroid Build Coastguard Worker  %sel = select <32 x i1> <i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 true, i1 true>, <32 x i8> %a, <32 x i8> %b
122*9880d681SAndroid Build Coastguard Worker  ret <32 x i8> %sel
123*9880d681SAndroid Build Coastguard Worker}
124*9880d681SAndroid Build Coastguard Worker
125