1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
3 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mcpu=neoverse-n1 | FileCheck %s
4 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mcpu=neoverse-n2 | FileCheck %s
5 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mcpu=neoverse-v1 | FileCheck %s
6 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mcpu=neoverse-v2 | FileCheck %s
7 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -mcpu=kryo | FileCheck %s --check-prefix=KRYO
9 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
10 target triple = "aarch64--linux-gnu"
12 define void @vectorInstrCost() {
13 ; CHECK-LABEL: 'vectorInstrCost'
14 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ta0 = extractelement <8 x i1> undef, i32 0
15 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ta1 = extractelement <8 x i1> undef, i32 1
16 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t1 = extractelement <8 x i8> undef, i32 0
17 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t2 = extractelement <8 x i8> undef, i32 1
18 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t3 = extractelement <4 x i16> undef, i32 0
19 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t4 = extractelement <4 x i16> undef, i32 1
20 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t5 = extractelement <2 x i32> undef, i32 0
21 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t6 = extractelement <2 x i32> undef, i32 1
22 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t7 = extractelement <2 x i64> undef, i32 0
23 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t8 = extractelement <2 x i64> undef, i32 1
24 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t9 = extractelement <4 x half> undef, i32 0
25 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t10 = extractelement <4 x half> undef, i32 1
26 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t11 = extractelement <2 x float> undef, i32 0
27 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t12 = extractelement <2 x float> undef, i32 1
28 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t13 = extractelement <2 x double> undef, i32 0
29 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t14 = extractelement <2 x double> undef, i32 1
30 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %t31 = insertelement <8 x i1> undef, i1 false, i32 0
31 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %t41 = insertelement <8 x i1> undef, i1 true, i32 1
32 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t30 = insertelement <8 x i8> undef, i8 0, i32 0
33 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t40 = insertelement <8 x i8> undef, i8 1, i32 1
34 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t50 = insertelement <4 x i16> undef, i16 2, i32 0
35 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t60 = insertelement <4 x i16> undef, i16 3, i32 1
36 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t70 = insertelement <2 x i32> undef, i32 4, i32 0
37 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t80 = insertelement <2 x i32> undef, i32 5, i32 1
38 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t90 = insertelement <2 x i64> undef, i64 6, i32 0
39 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t100 = insertelement <2 x i64> undef, i64 7, i32 1
40 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t110 = insertelement <4 x half> zeroinitializer, half 0xH0000, i64 0
41 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t120 = insertelement <4 x half> zeroinitializer, half 0xH0000, i64 1
42 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t130 = insertelement <2 x float> zeroinitializer, float 0.000000e+00, i64 0
43 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t140 = insertelement <2 x float> zeroinitializer, float 0.000000e+00, i64 1
44 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t150 = insertelement <2 x double> zeroinitializer, double 0.000000e+00, i64 0
45 ; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t160 = insertelement <2 x double> zeroinitializer, double 0.000000e+00, i64 1
46 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
48 ; KRYO-LABEL: 'vectorInstrCost'
49 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ta0 = extractelement <8 x i1> undef, i32 0
50 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %ta1 = extractelement <8 x i1> undef, i32 1
51 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t1 = extractelement <8 x i8> undef, i32 0
52 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t2 = extractelement <8 x i8> undef, i32 1
53 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t3 = extractelement <4 x i16> undef, i32 0
54 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t4 = extractelement <4 x i16> undef, i32 1
55 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t5 = extractelement <2 x i32> undef, i32 0
56 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t6 = extractelement <2 x i32> undef, i32 1
57 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t7 = extractelement <2 x i64> undef, i32 0
58 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t8 = extractelement <2 x i64> undef, i32 1
59 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t9 = extractelement <4 x half> undef, i32 0
60 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t10 = extractelement <4 x half> undef, i32 1
61 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t11 = extractelement <2 x float> undef, i32 0
62 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t12 = extractelement <2 x float> undef, i32 1
63 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t13 = extractelement <2 x double> undef, i32 0
64 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t14 = extractelement <2 x double> undef, i32 1
65 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %t31 = insertelement <8 x i1> undef, i1 false, i32 0
66 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %t41 = insertelement <8 x i1> undef, i1 true, i32 1
67 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t30 = insertelement <8 x i8> undef, i8 0, i32 0
68 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t40 = insertelement <8 x i8> undef, i8 1, i32 1
69 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t50 = insertelement <4 x i16> undef, i16 2, i32 0
70 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t60 = insertelement <4 x i16> undef, i16 3, i32 1
71 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t70 = insertelement <2 x i32> undef, i32 4, i32 0
72 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t80 = insertelement <2 x i32> undef, i32 5, i32 1
73 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t90 = insertelement <2 x i64> undef, i64 6, i32 0
74 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t100 = insertelement <2 x i64> undef, i64 7, i32 1
75 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t110 = insertelement <4 x half> zeroinitializer, half 0xH0000, i64 0
76 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t120 = insertelement <4 x half> zeroinitializer, half 0xH0000, i64 1
77 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t130 = insertelement <2 x float> zeroinitializer, float 0.000000e+00, i64 0
78 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t140 = insertelement <2 x float> zeroinitializer, float 0.000000e+00, i64 1
79 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %t150 = insertelement <2 x double> zeroinitializer, double 0.000000e+00, i64 0
80 ; KRYO-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %t160 = insertelement <2 x double> zeroinitializer, double 0.000000e+00, i64 1
81 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
84 %ta0 = extractelement <8 x i1> undef, i32 0
85 %ta1 = extractelement <8 x i1> undef, i32 1
86 %t1 = extractelement <8 x i8> undef, i32 0
87 %t2 = extractelement <8 x i8> undef, i32 1
88 %t3 = extractelement <4 x i16> undef, i32 0
89 %t4 = extractelement <4 x i16> undef, i32 1
90 %t5 = extractelement <2 x i32> undef, i32 0
91 %t6 = extractelement <2 x i32> undef, i32 1
92 %t7 = extractelement <2 x i64> undef, i32 0
93 %t8 = extractelement <2 x i64> undef, i32 1
94 %t9 = extractelement <4 x half> undef, i32 0
95 %t10 = extractelement <4 x half> undef, i32 1
96 %t11 = extractelement <2 x float> undef, i32 0
97 %t12 = extractelement <2 x float> undef, i32 1
98 %t13 = extractelement <2 x double> undef, i32 0
99 %t14 = extractelement <2 x double> undef, i32 1
101 %t31 = insertelement <8 x i1> undef, i1 0, i32 0
102 %t41 = insertelement <8 x i1> undef, i1 1, i32 1
103 %t30 = insertelement <8 x i8> undef, i8 0, i32 0
104 %t40 = insertelement <8 x i8> undef, i8 1, i32 1
105 %t50 = insertelement <4 x i16> undef, i16 2, i32 0
106 %t60 = insertelement <4 x i16> undef, i16 3, i32 1
107 %t70 = insertelement <2 x i32> undef, i32 4, i32 0
108 %t80 = insertelement <2 x i32> undef, i32 5, i32 1
109 %t90 = insertelement <2 x i64> undef, i64 6, i32 0
110 %t100 = insertelement <2 x i64> undef, i64 7, i32 1
111 %t110 = insertelement <4 x half> zeroinitializer, half 0.000000e+00, i64 0
112 %t120 = insertelement <4 x half> zeroinitializer, half 0.000000e+00, i64 1
113 %t130 = insertelement <2 x float> zeroinitializer, float 0.000000e+00, i64 0
114 %t140 = insertelement <2 x float> zeroinitializer, float 0.000000e+00, i64 1
115 %t150 = insertelement <2 x double> zeroinitializer, double 0.000000e+00, i64 0
116 %t160 = insertelement <2 x double> zeroinitializer, double 0.000000e+00, i64 1
120 ;; LD1: Load one single-element structure to one lane of one register.
122 define <8 x i8> @LD1_B(<8 x i8> %vec, ptr noundef %i) {
123 ; CHECK-LABEL: 'LD1_B'
124 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i8, ptr %i, align 1
125 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <8 x i8> %vec, i8 %v1, i32 1
126 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %v2
128 ; KRYO-LABEL: 'LD1_B'
129 ; KRYO-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i8, ptr %i, align 1
130 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <8 x i8> %vec, i8 %v1, i32 1
131 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %v2
134 %v1 = load i8, ptr %i, align 1
135 %v2 = insertelement <8 x i8> %vec, i8 %v1, i32 1
139 define <4 x i16> @LD1_H(<4 x i16> %vec, ptr noundef %i) {
140 ; CHECK-LABEL: 'LD1_H'
141 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i16, ptr %i, align 2
142 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <4 x i16> %vec, i16 %v1, i32 2
143 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i16> %v2
145 ; KRYO-LABEL: 'LD1_H'
146 ; KRYO-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i16, ptr %i, align 2
147 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <4 x i16> %vec, i16 %v1, i32 2
148 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i16> %v2
151 %v1 = load i16, ptr %i, align 2
152 %v2 = insertelement <4 x i16> %vec, i16 %v1, i32 2
156 define <4 x i32> @LD1_W(<4 x i32> %vec, ptr noundef %i) {
157 ; CHECK-LABEL: 'LD1_W'
158 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i32, ptr %i, align 4
159 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <4 x i32> %vec, i32 %v1, i32 3
160 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %v2
162 ; KRYO-LABEL: 'LD1_W'
163 ; KRYO-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i32, ptr %i, align 4
164 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <4 x i32> %vec, i32 %v1, i32 3
165 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %v2
168 %v1 = load i32, ptr %i, align 4
169 %v2 = insertelement <4 x i32> %vec, i32 %v1, i32 3
173 define <2 x i64> @LD1_X(<2 x i64> %vec, ptr noundef %i) {
174 ; CHECK-LABEL: 'LD1_X'
175 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i64, ptr %i, align 8
176 ; CHECK-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <2 x i64> %vec, i64 %v1, i32 0
177 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %v2
179 ; KRYO-LABEL: 'LD1_X'
180 ; KRYO-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v1 = load i64, ptr %i, align 8
181 ; KRYO-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <2 x i64> %vec, i64 %v1, i32 0
182 ; KRYO-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %v2
185 %v1 = load i64, ptr %i, align 8
186 %v2 = insertelement <2 x i64> %vec, i64 %v1, i32 0