1 ; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s
3 ; Check icmp for legal integer vectors.
4 define void @cmp_legal_int() {
5 ; CHECK-LABEL: 'cmp_legal_int'
6 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %1 = icmp ne <vscale x 2 x i64> undef, undef
7 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %2 = icmp ne <vscale x 4 x i32> undef, undef
8 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %3 = icmp ne <vscale x 8 x i16> undef, undef
9 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = icmp ne <vscale x 16 x i8> undef, undef
10 %1 = icmp ne <vscale x 2 x i64> undef, undef
11 %2 = icmp ne <vscale x 4 x i32> undef, undef
12 %3 = icmp ne <vscale x 8 x i16> undef, undef
13 %4 = icmp ne <vscale x 16 x i8> undef, undef
17 ; Check icmp for an illegal integer vector.
18 define <vscale x 4 x i1> @cmp_nxv4i64() {
19 ; CHECK-LABEL: 'cmp_nxv4i64'
20 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res = icmp ne <vscale x 4 x i64> undef, undef
21 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 4 x i1> %res
22 %res = icmp ne <vscale x 4 x i64> undef, undef
23 ret <vscale x 4 x i1> %res
26 ; Check icmp for legal predicate vectors.
27 define void @cmp_legal_pred() {
28 ; CHECK-LABEL: 'cmp_legal_pred'
29 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %1 = icmp ne <vscale x 2 x i1> undef, undef
30 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %2 = icmp ne <vscale x 4 x i1> undef, undef
31 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %3 = icmp ne <vscale x 8 x i1> undef, undef
32 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = icmp ne <vscale x 16 x i1> undef, undef
33 %1 = icmp ne <vscale x 2 x i1> undef, undef
34 %2 = icmp ne <vscale x 4 x i1> undef, undef
35 %3 = icmp ne <vscale x 8 x i1> undef, undef
36 %4 = icmp ne <vscale x 16 x i1> undef, undef
40 ; Check icmp for an illegal predicate vector.
41 define <vscale x 32 x i1> @cmp_nxv32i1() {
42 ; CHECK-LABEL: 'cmp_nxv32i1'
43 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res = icmp ne <vscale x 32 x i1> undef, undef
44 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i1> %res
45 %res = icmp ne <vscale x 32 x i1> undef, undef
46 ret <vscale x 32 x i1> %res
49 ; Check fcmp for legal FP vectors
50 define void @cmp_legal_fp() #0 {
51 ; CHECK-LABEL: 'cmp_legal_fp'
52 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %1 = fcmp oge <vscale x 2 x double> undef, undef
53 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %2 = fcmp oge <vscale x 4 x float> undef, undef
54 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %3 = fcmp oge <vscale x 8 x half> undef, undef
55 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = fcmp oge <vscale x 8 x bfloat> undef, undef
56 %1 = fcmp oge <vscale x 2 x double> undef, undef
57 %2 = fcmp oge <vscale x 4 x float> undef, undef
58 %3 = fcmp oge <vscale x 8 x half> undef, undef
59 %4 = fcmp oge <vscale x 8 x bfloat> undef, undef
63 ; Check fcmp for an illegal FP vector
64 define <vscale x 16 x i1> @cmp_nxv16f16() {
65 ; CHECK-LABEL: 'cmp_nxv16f16'
66 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %res = fcmp oge <vscale x 16 x half> undef, undef
67 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i1> %res
68 %res = fcmp oge <vscale x 16 x half> undef, undef
69 ret <vscale x 16 x i1> %res
72 ; Check select for legal integer vectors
73 define void @sel_legal_int() {
74 ; CHECK-LABEL: 'sel_legal_int'
75 ; 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
76 ; 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
77 ; 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
78 ; 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
79 %1 = select <vscale x 2 x i1> undef, <vscale x 2 x i64> undef, <vscale x 2 x i64> undef
80 %2 = select <vscale x 4 x i1> undef, <vscale x 4 x i32> undef, <vscale x 4 x i32> undef
81 %3 = select <vscale x 8 x i1> undef, <vscale x 8 x i16> undef, <vscale x 8 x i16> undef
82 %4 = select <vscale x 16 x i1> undef, <vscale x 16 x i8> undef, <vscale x 16 x i8> undef
86 ; Check select for an illegal integer vector
87 define <vscale x 16 x i16> @sel_nxv16i16() {
88 ; CHECK-LABEL: 'sel_nxv16i16'
89 ; 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
90 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 16 x i16> %res
91 %res = select <vscale x 16 x i1> undef, <vscale x 16 x i16> undef, <vscale x 16 x i16> undef
92 ret <vscale x 16 x i16> %res
95 ; Check select for a legal FP vector
96 define void @sel_legal_fp() #0 {
97 ; CHECK-LABEL: 'sel_legal_fp'
98 ; 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
99 ; 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
100 ; 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
101 ; 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
102 %1 = select <vscale x 2 x i1> undef, <vscale x 2 x double> undef, <vscale x 2 x double> undef
103 %2 = select <vscale x 4 x i1> undef, <vscale x 4 x float> undef, <vscale x 4 x float> undef
104 %3 = select <vscale x 8 x i1> undef, <vscale x 8 x half> undef, <vscale x 8 x half> undef
105 %4 = select <vscale x 8 x i1> undef, <vscale x 8 x bfloat> undef, <vscale x 8 x bfloat> undef
109 ; Check select for an illegal FP vector
110 define <vscale x 8 x float> @sel_nxv8f32() {
111 ; CHECK-LABEL: 'sel_nxv8f32'
112 ; 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
113 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 8 x float> %res
114 %res = select <vscale x 8 x i1> undef, <vscale x 8 x float> undef, <vscale x 8 x float> undef
115 ret <vscale x 8 x float> %res
118 ; Check select for a legal predicate vector
119 define void @sel_legal_pred() {
120 ; CHECK-LABEL: 'sel_legal_pred'
121 ; 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
122 ; 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
123 ; 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
124 ; 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
125 %1 = select <vscale x 2 x i1> undef, <vscale x 2 x i1> undef, <vscale x 2 x i1> undef
126 %2 = select <vscale x 4 x i1> undef, <vscale x 4 x i1> undef, <vscale x 4 x i1> undef
127 %3 = select <vscale x 8 x i1> undef, <vscale x 8 x i1> undef, <vscale x 8 x i1> undef
128 %4 = select <vscale x 16 x i1> undef, <vscale x 16 x i1> undef, <vscale x 16 x i1> undef
132 ; Check select for an illegal predicate vector
133 define <vscale x 32 x i1> @sel_nxv32i1() {
134 ; CHECK-LABEL: 'sel_nxv32i1'
135 ; 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
136 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: ret <vscale x 32 x i1> %res
137 %res = select <vscale x 32 x i1> undef, <vscale x 32 x i1> undef, <vscale x 32 x i1> undef
138 ret <vscale x 32 x i1> %res
141 attributes #0 = { "target-features"="+sve,+bf16" }