xref: /llvm-project/llvm/test/Analysis/CostModel/AArch64/sve-cmpsel.ll (revision 75f1b328f8fb2468e8bef618b022ad8ce928097d)
1; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64--linux-gnu -mattr=+sve  < %s | FileCheck %s
2
3target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4
5; Check icmp for legal integer vectors.
6define void @cmp_legal_int() {
7; CHECK-LABEL: 'cmp_legal_int'
8; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %1 = icmp ne <vscale x 2 x i64> undef, undef
9; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %2 = icmp ne <vscale x 4 x i32> undef, undef
10; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %3 = icmp ne <vscale x 8 x i16> undef, undef
11; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %4 = icmp ne <vscale x 16 x i8> undef, undef
12  %1 = icmp ne <vscale x 2 x i64> undef, undef
13  %2 = icmp ne <vscale x 4 x i32> undef, undef
14  %3 = icmp ne <vscale x 8 x i16> undef, undef
15  %4 = icmp ne <vscale x 16 x i8> undef, undef
16  ret void
17}
18
19; Check icmp for an illegal integer vector.
20define <vscale x 4 x i1> @cmp_nxv4i64() {
21; CHECK-LABEL: 'cmp_nxv4i64'
22; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = icmp ne <vscale x 4 x i64> undef, undef
23; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 4 x i1> %res
24  %res = icmp ne <vscale x 4 x i64> undef, undef
25  ret <vscale x 4 x i1> %res
26}
27
28; Check icmp for legal predicate vectors.
29define void @cmp_legal_pred() {
30; CHECK-LABEL: 'cmp_legal_pred'
31; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %1 = icmp ne <vscale x 2 x i1> undef, undef
32; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %2 = icmp ne <vscale x 4 x i1> undef, undef
33; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %3 = icmp ne <vscale x 8 x i1> undef, undef
34; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %4 = icmp ne <vscale x 16 x i1> undef, undef
35  %1 = icmp ne <vscale x 2 x i1> undef, undef
36  %2 = icmp ne <vscale x 4 x i1> undef, undef
37  %3 = icmp ne <vscale x 8 x i1> undef, undef
38  %4 = icmp ne <vscale x 16 x i1> undef, undef
39  ret void
40}
41
42; Check icmp for an illegal predicate vector.
43define <vscale x 32 x i1> @cmp_nxv32i1() {
44; CHECK-LABEL: 'cmp_nxv32i1'
45; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = icmp ne <vscale x 32 x i1> undef, undef
46; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 32 x i1> %res
47  %res = icmp ne <vscale x 32 x i1> undef, undef
48  ret <vscale x 32 x i1> %res
49}
50
51; Check fcmp for legal FP vectors
52define void @cmp_legal_fp() #0 {
53; CHECK-LABEL: 'cmp_legal_fp'
54; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %1 = fcmp oge <vscale x 2 x double> undef, undef
55; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %2 = fcmp oge <vscale x 4 x float> undef, undef
56; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %3 = fcmp oge <vscale x 8 x half> undef, undef
57; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %4 = fcmp oge <vscale x 8 x bfloat> undef, undef
58  %1 = fcmp oge <vscale x 2 x double> undef, undef
59  %2 = fcmp oge <vscale x 4 x float> undef, undef
60  %3 = fcmp oge <vscale x 8 x half> undef, undef
61  %4 = fcmp oge <vscale x 8 x bfloat> undef, undef
62  ret void
63}
64
65; Check fcmp for an illegal FP vector
66define <vscale x 16 x i1> @cmp_nxv16f16() {
67; CHECK-LABEL: 'cmp_nxv16f16'
68; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = fcmp oge <vscale x 16 x half> undef, undef
69; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 16 x i1> %res
70  %res = fcmp oge <vscale x 16 x half> undef, undef
71  ret <vscale x 16 x i1> %res
72}
73
74; Check select for legal integer vectors
75define void @sel_legal_int() {
76; CHECK-LABEL: 'sel_legal_int'
77; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %1 = select <vscale x 2 x i1> undef, <vscale x 2 x i64> undef, <vscale x 2 x i64> undef
78; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %2 = select <vscale x 4 x i1> undef, <vscale x 4 x i32> undef, <vscale x 4 x i32> undef
79; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %3 = select <vscale x 8 x i1> undef, <vscale x 8 x i16> undef, <vscale x 8 x i16> undef
80; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %4 = select <vscale x 16 x i1> undef, <vscale x 16 x i8> undef, <vscale x 16 x i8> undef
81  %1 = select <vscale x 2 x i1> undef, <vscale x 2 x i64> undef, <vscale x 2 x i64> undef
82  %2 = select <vscale x 4 x i1> undef, <vscale x 4 x i32> undef, <vscale x 4 x i32> undef
83  %3 = select <vscale x 8 x i1> undef, <vscale x 8 x i16> undef, <vscale x 8 x i16> undef
84  %4 = select <vscale x 16 x i1> undef, <vscale x 16 x i8> undef, <vscale x 16 x i8> undef
85  ret void
86}
87
88; Check select for an illegal integer vector
89define <vscale x 16 x i16> @sel_nxv16i16() {
90; CHECK-LABEL: 'sel_nxv16i16'
91; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = select <vscale x 16 x i1> undef, <vscale x 16 x i16> undef, <vscale x 16 x i16> undef
92; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 16 x i16> %res
93  %res = select <vscale x 16 x i1> undef, <vscale x 16 x i16> undef, <vscale x 16 x i16> undef
94  ret <vscale x 16 x i16> %res
95}
96
97; Check select for a legal FP vector
98define void @sel_legal_fp() #0 {
99; CHECK-LABEL: 'sel_legal_fp'
100; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %1 = select <vscale x 2 x i1> undef, <vscale x 2 x double> undef, <vscale x 2 x double> undef
101; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %2 = select <vscale x 4 x i1> undef, <vscale x 4 x float> undef, <vscale x 4 x float> undef
102; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %3 = select <vscale x 8 x i1> undef, <vscale x 8 x half> undef, <vscale x 8 x half> undef
103; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %4 = select <vscale x 8 x i1> undef, <vscale x 8 x bfloat> undef, <vscale x 8 x bfloat> undef
104  %1 = select <vscale x 2 x i1> undef, <vscale x 2 x double> undef, <vscale x 2 x double> undef
105  %2 = select <vscale x 4 x i1> undef, <vscale x 4 x float> undef, <vscale x 4 x float> undef
106  %3 = select <vscale x 8 x i1> undef, <vscale x 8 x half> undef, <vscale x 8 x half> undef
107  %4 = select <vscale x 8 x i1> undef, <vscale x 8 x bfloat> undef, <vscale x 8 x bfloat> undef
108  ret void
109}
110
111; Check select for an illegal FP vector
112define <vscale x 8 x float> @sel_nxv8f32() {
113; CHECK-LABEL: 'sel_nxv8f32'
114; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = select <vscale x 8 x i1> undef, <vscale x 8 x float> undef, <vscale x 8 x float> undef
115; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 8 x float> %res
116  %res = select <vscale x 8 x i1> undef, <vscale x 8 x float> undef, <vscale x 8 x float> undef
117  ret <vscale x 8 x float> %res
118}
119
120; Check select for a legal predicate vector
121define void @sel_legal_pred() {
122; CHECK-LABEL: 'sel_legal_pred'
123; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %1 = select <vscale x 2 x i1> undef, <vscale x 2 x i1> undef, <vscale x 2 x i1> undef
124; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %2 = select <vscale x 4 x i1> undef, <vscale x 4 x i1> undef, <vscale x 4 x i1> undef
125; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %3 = select <vscale x 8 x i1> undef, <vscale x 8 x i1> undef, <vscale x 8 x i1> undef
126; CHECK: Cost Model: Found an estimated cost of 1 for instruction:   %4 = select <vscale x 16 x i1> undef, <vscale x 16 x i1> undef, <vscale x 16 x i1> undef
127  %1 = select <vscale x 2 x i1> undef, <vscale x 2 x i1> undef, <vscale x 2 x i1> undef
128  %2 = select <vscale x 4 x i1> undef, <vscale x 4 x i1> undef, <vscale x 4 x i1> undef
129  %3 = select <vscale x 8 x i1> undef, <vscale x 8 x i1> undef, <vscale x 8 x i1> undef
130  %4 = select <vscale x 16 x i1> undef, <vscale x 16 x i1> undef, <vscale x 16 x i1> undef
131  ret void
132}
133
134; Check select for an illegal predicate vector
135define <vscale x 32 x i1> @sel_nxv32i1() {
136; CHECK-LABEL: 'sel_nxv32i1'
137; CHECK: Cost Model: Found an estimated cost of 2 for instruction:   %res = select <vscale x 32 x i1> undef, <vscale x 32 x i1> undef, <vscale x 32 x i1> undef
138; CHECK: Cost Model: Found an estimated cost of 0 for instruction:   ret <vscale x 32 x i1> %res
139  %res = select <vscale x 32 x i1> undef, <vscale x 32 x i1> undef, <vscale x 32 x i1> undef
140  ret <vscale x 32 x i1> %res
141}
142
143attributes #0 = { "target-features"="+sve,+bf16" }
144