1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -mtriple=riscv32 -cost-model -analyze < %s \
3 ; RUN: | FileCheck %s -check-prefix=RVI
4 ; RUN: opt -mtriple=riscv64 -cost-model -analyze < %s \
5 ; RUN: | FileCheck %s -check-prefix=RVI
7 define void @testi8(i8* %a, i32 %i) {
9 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds i8, i8* %a, i32 0
10 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds i8, i8* %a, i32 1
11 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds i8, i8* %a, i32 -1
12 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds i8, i8* %a, i32 2047
13 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a4 = getelementptr inbounds i8, i8* %a, i32 2048
14 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds i8, i8* %a, i32 -2048
15 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a6 = getelementptr inbounds i8, i8* %a, i32 -2049
16 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ai = getelementptr inbounds i8, i8* %a, i32 %i
17 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
19 %a0 = getelementptr inbounds i8, i8* %a, i32 0
20 %a1 = getelementptr inbounds i8, i8* %a, i32 1
21 %a2 = getelementptr inbounds i8, i8* %a, i32 -1
22 %a3 = getelementptr inbounds i8, i8* %a, i32 2047
23 %a4 = getelementptr inbounds i8, i8* %a, i32 2048
24 %a5 = getelementptr inbounds i8, i8* %a, i32 -2048
25 %a6 = getelementptr inbounds i8, i8* %a, i32 -2049
26 %ai = getelementptr inbounds i8, i8* %a, i32 %i
30 define void @testi16(i16* %a, i32 %i) {
31 ; RVI-LABEL: 'testi16'
32 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds i16, i16* %a, i32 0
33 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds i16, i16* %a, i32 1
34 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds i16, i16* %a, i32 -1
35 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds i16, i16* %a, i32 1023
36 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a4 = getelementptr inbounds i16, i16* %a, i32 1024
37 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds i16, i16* %a, i32 -1024
38 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a6 = getelementptr inbounds i16, i16* %a, i32 -1025
39 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ai = getelementptr inbounds i16, i16* %a, i32 %i
40 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
42 %a0 = getelementptr inbounds i16, i16* %a, i32 0
43 %a1 = getelementptr inbounds i16, i16* %a, i32 1
44 %a2 = getelementptr inbounds i16, i16* %a, i32 -1
45 %a3 = getelementptr inbounds i16, i16* %a, i32 1023
46 %a4 = getelementptr inbounds i16, i16* %a, i32 1024
47 %a5 = getelementptr inbounds i16, i16* %a, i32 -1024
48 %a6 = getelementptr inbounds i16, i16* %a, i32 -1025
49 %ai = getelementptr inbounds i16, i16* %a, i32 %i
53 define void @testi32(i32* %a, i32 %i) {
54 ; RVI-LABEL: 'testi32'
55 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds i32, i32* %a, i32 0
56 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds i32, i32* %a, i32 1
57 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds i32, i32* %a, i32 -1
58 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds i32, i32* %a, i32 511
59 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a4 = getelementptr inbounds i32, i32* %a, i32 512
60 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds i32, i32* %a, i32 -512
61 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a6 = getelementptr inbounds i32, i32* %a, i32 -513
62 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ai = getelementptr inbounds i32, i32* %a, i32 %i
63 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
65 %a0 = getelementptr inbounds i32, i32* %a, i32 0
66 %a1 = getelementptr inbounds i32, i32* %a, i32 1
67 %a2 = getelementptr inbounds i32, i32* %a, i32 -1
68 %a3 = getelementptr inbounds i32, i32* %a, i32 511
69 %a4 = getelementptr inbounds i32, i32* %a, i32 512
70 %a5 = getelementptr inbounds i32, i32* %a, i32 -512
71 %a6 = getelementptr inbounds i32, i32* %a, i32 -513
72 %ai = getelementptr inbounds i32, i32* %a, i32 %i
76 define void @testi64(i64* %a, i32 %i) {
77 ; RVI-LABEL: 'testi64'
78 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds i64, i64* %a, i32 0
79 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds i64, i64* %a, i32 1
80 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds i64, i64* %a, i32 -1
81 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds i64, i64* %a, i32 255
82 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a4 = getelementptr inbounds i64, i64* %a, i32 256
83 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds i64, i64* %a, i32 -256
84 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a6 = getelementptr inbounds i64, i64* %a, i32 -257
85 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ai = getelementptr inbounds i64, i64* %a, i32 %i
86 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
88 %a0 = getelementptr inbounds i64, i64* %a, i32 0
89 %a1 = getelementptr inbounds i64, i64* %a, i32 1
90 %a2 = getelementptr inbounds i64, i64* %a, i32 -1
91 %a3 = getelementptr inbounds i64, i64* %a, i32 255
92 %a4 = getelementptr inbounds i64, i64* %a, i32 256
93 %a5 = getelementptr inbounds i64, i64* %a, i32 -256
94 %a6 = getelementptr inbounds i64, i64* %a, i32 -257
95 %ai = getelementptr inbounds i64, i64* %a, i32 %i
99 define void @testfloat(float* %a, i32 %i) {
100 ; RVI-LABEL: 'testfloat'
101 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds float, float* %a, i32 0
102 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds float, float* %a, i32 1
103 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds float, float* %a, i32 -1
104 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds float, float* %a, i32 511
105 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a4 = getelementptr inbounds float, float* %a, i32 512
106 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds float, float* %a, i32 -512
107 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a6 = getelementptr inbounds float, float* %a, i32 -513
108 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ai = getelementptr inbounds float, float* %a, i32 %i
109 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
111 %a0 = getelementptr inbounds float, float* %a, i32 0
112 %a1 = getelementptr inbounds float, float* %a, i32 1
113 %a2 = getelementptr inbounds float, float* %a, i32 -1
114 %a3 = getelementptr inbounds float, float* %a, i32 511
115 %a4 = getelementptr inbounds float, float* %a, i32 512
116 %a5 = getelementptr inbounds float, float* %a, i32 -512
117 %a6 = getelementptr inbounds float, float* %a, i32 -513
118 %ai = getelementptr inbounds float, float* %a, i32 %i
122 define void @testdouble(double* %a, i32 %i) {
123 ; RVI-LABEL: 'testdouble'
124 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds double, double* %a, i32 0
125 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds double, double* %a, i32 1
126 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds double, double* %a, i32 -1
127 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds double, double* %a, i32 255
128 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a4 = getelementptr inbounds double, double* %a, i32 256
129 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds double, double* %a, i32 -256
130 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a6 = getelementptr inbounds double, double* %a, i32 -257
131 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ai = getelementptr inbounds double, double* %a, i32 %i
132 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
134 %a0 = getelementptr inbounds double, double* %a, i32 0
135 %a1 = getelementptr inbounds double, double* %a, i32 1
136 %a2 = getelementptr inbounds double, double* %a, i32 -1
137 %a3 = getelementptr inbounds double, double* %a, i32 255
138 %a4 = getelementptr inbounds double, double* %a, i32 256
139 %a5 = getelementptr inbounds double, double* %a, i32 -256
140 %a6 = getelementptr inbounds double, double* %a, i32 -257
141 %ai = getelementptr inbounds double, double* %a, i32 %i
145 define void @testvecs(i32 %i) {
146 ; RVI-LABEL: 'testvecs'
147 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a0 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 0
148 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a1 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 0
149 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a2 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 0
150 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a3 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 0
151 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a4 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 0
152 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a5 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 0
153 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %b0 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 1
154 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %b1 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 1
155 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %b2 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 1
156 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %b3 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 1
157 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %b4 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 1
158 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %b5 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 1
159 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %c1 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 128
160 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %c2 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 128
161 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c3 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 128
162 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c4 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 128
163 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c5 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 128
164 ; RVI-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %c6 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 128
165 ; RVI-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
167 %a0 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 0
168 %a1 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 0
169 %a2 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 0
170 %a3 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 0
171 %a4 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 0
172 %a5 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 0
174 %b0 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 1
175 %b1 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 1
176 %b2 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 1
177 %b3 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 1
178 %b4 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 1
179 %b5 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 1
181 %c1 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 128
182 %c2 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 128
183 %c3 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 128
184 %c4 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 128
185 %c5 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 128
186 %c6 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 128