File: sil_combine_same_ops_ossa.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (293 lines) | stat: -rw-r--r-- 10,893 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
// RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine | %FileCheck %s

// Test optimization of various builtins which receive the same value in their first and second operand.

sil_stage canonical

import Builtin
import Swift

// CHECK-LABEL: sil [ossa] @tst_ssub
// CHECK: %1 = integer_literal $Builtin.Int32, 0
// CHECK: %2 = struct $Int32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_ssub : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = integer_literal $Builtin.Int1, -1
  %3 = builtin "ssub_with_overflow_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32, %2 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
  %4 = tuple_extract %3 : $(Builtin.Int32, Builtin.Int1), 0
  %5 = tuple_extract %3 : $(Builtin.Int32, Builtin.Int1), 1
  cond_fail %5 : $Builtin.Int1
  %7 = struct $Int32 (%4 : $Builtin.Int32)
  return %7 : $Int32
}

// CHECK-LABEL: sil [ossa] @tst_usub
// CHECK: %1 = integer_literal $Builtin.Int32, 0
// CHECK: %2 = struct $UInt32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_usub : $@convention(thin) (UInt32) -> UInt32 {
bb0(%0 : $UInt32):
  %1 = struct_extract %0 : $UInt32, #UInt32._value
  %2 = integer_literal $Builtin.Int1, -1
  %3 = builtin "usub_with_overflow_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32, %2 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
  %4 = tuple_extract %3 : $(Builtin.Int32, Builtin.Int1), 0
  %5 = tuple_extract %3 : $(Builtin.Int32, Builtin.Int1), 1
  cond_fail %5 : $Builtin.Int1
  %7 = struct $UInt32 (%4 : $Builtin.Int32)
  return %7 : $UInt32
}

// CHECK-LABEL: sil [ossa] @tst_sdiv
// CHECK: %1 = integer_literal $Builtin.Int32, 1
// CHECK: %2 = struct $Int32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_sdiv : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
  %1 = integer_literal $Builtin.Int32, 0
  %2 = struct_extract %0 : $Int32, #Int32._value
  %3 = builtin "sdiv_Int32"(%2 : $Builtin.Int32, %2 : $Builtin.Int32) : $Builtin.Int32
  %4 = struct $Int32 (%3 : $Builtin.Int32)
  return %4 : $Int32
}

// CHECK-LABEL: sil [ossa] @tst_udiv
// CHECK: %1 = integer_literal $Builtin.Int32, 1
// CHECK: %2 = struct $UInt32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_udiv : $@convention(thin) (UInt32) -> UInt32 {
bb0(%0 : $UInt32):
  %1 = integer_literal $Builtin.Int32, 0
  %2 = struct_extract %0 : $UInt32, #UInt32._value
  %3 = builtin "udiv_Int32"(%2 : $Builtin.Int32, %2 : $Builtin.Int32) : $Builtin.Int32
  %4 = struct $UInt32 (%3 : $Builtin.Int32)
  return %4 : $UInt32
}

// CHECK-LABEL: sil [ossa] @tst_srem
// CHECK: %1 = integer_literal $Builtin.Int32, 0
// CHECK: %2 = struct $Int32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_srem : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
  %1 = integer_literal $Builtin.Int32, 0
  %2 = struct_extract %0 : $Int32, #Int32._value
  %3 = builtin "srem_Int32"(%2 : $Builtin.Int32, %2 : $Builtin.Int32) : $Builtin.Int32
  %4 = struct $Int32 (%3 : $Builtin.Int32)
  return %4 : $Int32
}

// CHECK-LABEL: sil [ossa] @tst_urem
// CHECK: %1 = integer_literal $Builtin.Int32, 0
// CHECK: %2 = struct $UInt32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_urem : $@convention(thin) (UInt32) -> UInt32 {
bb0(%0 : $UInt32):
  %1 = integer_literal $Builtin.Int32, 0
  %2 = struct_extract %0 : $UInt32, #UInt32._value
  %3 = builtin "urem_Int32"(%2 : $Builtin.Int32, %2 : $Builtin.Int32) : $Builtin.Int32
  %4 = struct $UInt32 (%3 : $Builtin.Int32)
  return %4 : $UInt32
}

// CHECK-LABEL: sil [ossa] @tst_and
// CHECK: return %0
sil [ossa] @tst_and : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "and_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int32
  %3 = struct $Int32 (%2 : $Builtin.Int32)
  return %3 : $Int32
}

// CHECK-LABEL: sil [ossa] @tst_or
// CHECK: return %0
sil [ossa] @tst_or : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "or_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int32
  %3 = struct $Int32 (%2 : $Builtin.Int32)
  return %3 : $Int32
}

// CHECK-LABEL: sil [ossa] @tst_xor
// CHECK: %1 = integer_literal $Builtin.Int32, 0
// CHECK: %2 = struct $Int32 (%1 : $Builtin.Int32)
// CHECK: return %2
sil [ossa] @tst_xor : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "xor_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int32
  %3 = struct $Int32 (%2 : $Builtin.Int32)
  return %3 : $Int32
}

// CHECK-LABEL: sil [ossa] @tst_icmp_eq
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_eq : $@convention(thin) (Int32) -> Bool {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "cmp_eq_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_ne
// CHECK: %1 = integer_literal $Builtin.Int1, 0
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_ne : $@convention(thin) (Int32) -> Bool {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "cmp_ne_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_sle
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_sle : $@convention(thin) (Int32) -> Bool {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "cmp_sle_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_sge
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_sge : $@convention(thin) (Int32) -> Bool {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "cmp_sge_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_slt
// CHECK: %1 = integer_literal $Builtin.Int1, 0
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_slt : $@convention(thin) (Int32) -> Bool {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "cmp_slt_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_sgt
// CHECK: %1 = integer_literal $Builtin.Int1, 0
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_sgt : $@convention(thin) (Int32) -> Bool {
bb0(%0 : $Int32):
  %1 = struct_extract %0 : $Int32, #Int32._value
  %2 = builtin "cmp_sgt_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_ule
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_ule : $@convention(thin) (UInt32) -> Bool {
bb0(%0 : $UInt32):
  %1 = struct_extract %0 : $UInt32, #UInt32._value
  %2 = builtin "cmp_ule_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_uge
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_uge : $@convention(thin) (UInt32) -> Bool {
bb0(%0 : $UInt32):
  %1 = struct_extract %0 : $UInt32, #UInt32._value
  %2 = builtin "cmp_uge_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_ult
// CHECK: %1 = integer_literal $Builtin.Int1, 0
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_ult : $@convention(thin) (UInt32) -> Bool {
bb0(%0 : $UInt32):
  %1 = struct_extract %0 : $UInt32, #UInt32._value
  %2 = builtin "cmp_ult_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_icmp_ugt
// CHECK: %1 = integer_literal $Builtin.Int1, 0
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_icmp_ugt : $@convention(thin) (UInt32) -> Bool {
bb0(%0 : $UInt32):
  %1 = struct_extract %0 : $UInt32, #UInt32._value
  %2 = builtin "cmp_ugt_Int32"(%1 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_fcmp_ueq
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_fcmp_ueq : $@convention(thin) (Float) -> Bool {
bb0(%0 : $Float):
  %1 = struct_extract %0 : $Float, #Float._value
  %2 = builtin "fcmp_ueq_FPIEEE32"(%1 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_fcmp_one
// CHECK: %1 = integer_literal $Builtin.Int1, 0
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_fcmp_one : $@convention(thin) (Float) -> Bool {
bb0(%0 : $Float):
  %1 = struct_extract %0 : $Float, #Float._value
  %2 = builtin "fcmp_one_FPIEEE32"(%1 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_fcmp_ule
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_fcmp_ule : $@convention(thin) (Float) -> Bool {
bb0(%0 : $Float):
  %1 = struct_extract %0 : $Float, #Float._value
  %2 = builtin "fcmp_ule_FPIEEE32"(%1 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}

// CHECK-LABEL: sil [ossa] @tst_fcmp_uge
// CHECK: %1 = integer_literal $Builtin.Int1, -1
// CHECK: %2 = struct $Bool (%1 : $Builtin.Int1)
// CHECK: return %2
sil [ossa] @tst_fcmp_uge : $@convention(thin) (Float) -> Bool {
bb0(%0 : $Float):
  %1 = struct_extract %0 : $Float, #Float._value
  %2 = builtin "fcmp_uge_FPIEEE32"(%1 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
  %3 = struct $Bool (%2 : $Builtin.Int1)
  return %3 : $Bool
}