1 // RUN: mlir-opt %s | mlir-opt | FileCheck %s
4 // CHECK-LABEL: func @baz
8 // CHECK-LABEL: func @ops
9 // CHECK-SAME: (%[[I32:.*]]: i32, %[[FLOAT:.*]]: f32, %[[PTR1:.*]]: !llvm.ptr, %[[PTR2:.*]]: !llvm.ptr, %[[BOOL:.*]]: i1, %[[VPTR1:.*]]: !llvm.vec<2 x ptr>)
10 func.func @ops(%arg0: i32, %arg1: f32,
11 %arg2: !llvm.ptr, %arg3: !llvm.ptr,
12 %arg4: i1, %arg5 : !llvm.vec<2x!llvm.ptr>) {
13 // Integer arithmetic binary operations.
15 // CHECK: {{.*}} = llvm.add %[[I32]], %[[I32]] : i32
16 // CHECK: {{.*}} = llvm.sub %[[I32]], %[[I32]] : i32
17 // CHECK: {{.*}} = llvm.mul %[[I32]], %[[I32]] : i32
18 // CHECK: {{.*}} = llvm.udiv %[[I32]], %[[I32]] : i32
19 // CHECK: {{.*}} = llvm.sdiv %[[I32]], %[[I32]] : i32
20 // CHECK: {{.*}} = llvm.urem %[[I32]], %[[I32]] : i32
21 // CHECK: {{.*}} = llvm.srem %[[I32]], %[[I32]] : i32
22 // CHECK: %[[SCALAR_PRED0:.+]] = llvm.icmp "ne" %[[I32]], %[[I32]] : i32
23 // CHECK: {{.*}} = llvm.add %[[SCALAR_PRED0]], %[[SCALAR_PRED0]] : i1
24 // CHECK: %[[SCALAR_PRED1:.+]] = llvm.icmp "ne" %[[PTR1]], %[[PTR1]] : !llvm.ptr
25 // CHECK: {{.*}} = llvm.add %[[SCALAR_PRED1]], %[[SCALAR_PRED1]] : i1
26 // CHECK: %[[VEC_PRED:.+]] = llvm.icmp "ne" %[[VPTR1]], %[[VPTR1]] : !llvm.vec<2 x ptr>
27 // CHECK: {{.*}} = llvm.add %[[VEC_PRED]], %[[VEC_PRED]] : vector<2xi1>
28 %0 = llvm.add %arg0, %arg0 : i32
29 %1 = llvm.sub %arg0, %arg0 : i32
30 %2 = llvm.mul %arg0, %arg0 : i32
31 %3 = llvm.udiv %arg0, %arg0 : i32
32 %4 = llvm.sdiv %arg0, %arg0 : i32
33 %5 = llvm.urem %arg0, %arg0 : i32
34 %6 = llvm.srem %arg0, %arg0 : i32
35 %7 = llvm.icmp "ne" %arg0, %arg0 : i32
36 %typecheck_7 = llvm.add %7, %7 : i1
37 %ptrcmp = llvm.icmp "ne" %arg2, %arg2 : !llvm.ptr
38 %typecheck_ptrcmp = llvm.add %ptrcmp, %ptrcmp : i1
39 %vptrcmp = llvm.icmp "ne" %arg5, %arg5 : !llvm.vec<2 x ptr>
40 %typecheck_vptrcmp = llvm.add %vptrcmp, %vptrcmp : vector<2 x i1>
42 // Integer overflow flags
43 // CHECK: {{.*}} = llvm.add %[[I32]], %[[I32]] overflow<nsw> : i32
44 // CHECK: {{.*}} = llvm.sub %[[I32]], %[[I32]] overflow<nuw> : i32
45 // CHECK: {{.*}} = llvm.mul %[[I32]], %[[I32]] overflow<nsw, nuw> : i32
46 // CHECK: {{.*}} = llvm.shl %[[I32]], %[[I32]] overflow<nsw, nuw> : i32
47 %add_flag = llvm.add %arg0, %arg0 overflow<nsw> : i32
48 %sub_flag = llvm.sub %arg0, %arg0 overflow<nuw> : i32
49 %mul_flag = llvm.mul %arg0, %arg0 overflow<nsw, nuw> : i32
50 %shl_flag = llvm.shl %arg0, %arg0 overflow<nuw, nsw> : i32
52 // Integer exact flag.
53 // CHECK: {{.*}} = llvm.sdiv exact %[[I32]], %[[I32]] : i32
54 // CHECK: {{.*}} = llvm.udiv exact %[[I32]], %[[I32]] : i32
55 // CHECK: {{.*}} = llvm.ashr exact %[[I32]], %[[I32]] : i32
56 // CHECK: {{.*}} = llvm.lshr exact %[[I32]], %[[I32]] : i32
57 %sdiv_flag = llvm.sdiv exact %arg0, %arg0 : i32
58 %udiv_flag = llvm.udiv exact %arg0, %arg0 : i32
59 %ashr_flag = llvm.ashr exact %arg0, %arg0 : i32
60 %lshr_flag = llvm.lshr exact %arg0, %arg0 : i32
62 // Integer disjoint flag.
63 // CHECK: {{.*}} = llvm.or disjoint %[[I32]], %[[I32]] : i32
64 %or_flag = llvm.or disjoint %arg0, %arg0 : i32
66 // Floating point binary operations.
68 // CHECK: {{.*}} = llvm.fadd %[[FLOAT]], %[[FLOAT]] : f32
69 // CHECK: {{.*}} = llvm.fsub %[[FLOAT]], %[[FLOAT]] : f32
70 // CHECK: {{.*}} = llvm.fmul %[[FLOAT]], %[[FLOAT]] : f32
71 // CHECK: {{.*}} = llvm.fdiv %[[FLOAT]], %[[FLOAT]] : f32
72 // CHECK: {{.*}} = llvm.frem %[[FLOAT]], %[[FLOAT]] : f32
73 %8 = llvm.fadd %arg1, %arg1 : f32
74 %9 = llvm.fsub %arg1, %arg1 : f32
75 %10 = llvm.fmul %arg1, %arg1 : f32
76 %11 = llvm.fdiv %arg1, %arg1 : f32
77 %12 = llvm.frem %arg1, %arg1 : f32
79 // Memory-related operations.
81 // CHECK-NEXT: %[[ALLOCA:.*]] = llvm.alloca %[[I32]] x f64 : (i32) -> !llvm.ptr
82 // CHECK-NEXT: %[[GEP:.*]] = llvm.getelementptr %[[ALLOCA]][%[[I32]]] : (!llvm.ptr, i32) -> !llvm.ptr, f64
83 // CHECK-NEXT: %[[VALUE:.*]] = llvm.load %[[GEP]] : !llvm.ptr -> f64
84 // CHECK-NEXT: llvm.store %[[VALUE]], %[[ALLOCA]] : f64, !llvm.ptr
85 %13 = llvm.alloca %arg0 x f64 : (i32) -> !llvm.ptr
86 %14 = llvm.getelementptr %13[%arg0] : (!llvm.ptr, i32) -> !llvm.ptr, f64
87 %15 = llvm.load %14 : !llvm.ptr -> f64
88 llvm.store %15, %13 : f64, !llvm.ptr
90 // Function call-related operations.
92 // CHECK: %[[STRUCT:.*]] = llvm.call @foo(%[[I32]]) : (i32) -> !llvm.struct<(i32, f64, i32)>
93 // CHECK: %[[VALUE:.*]] = llvm.extractvalue %[[STRUCT]][0] : !llvm.struct<(i32, f64, i32)>
94 // CHECK: %[[NEW_STRUCT:.*]] = llvm.insertvalue %[[VALUE]], %[[STRUCT]][2] : !llvm.struct<(i32, f64, i32)>
95 // CHECK: %[[FUNC:.*]] = llvm.mlir.addressof @foo : !llvm.ptr
96 // CHECK: %{{.*}} = llvm.call %[[FUNC]](%[[I32]]) : !llvm.ptr, (i32) -> !llvm.struct<(i32, f64, i32)>
97 %17 = llvm.call @foo(%arg0) : (i32) -> !llvm.struct<(i32, f64, i32)>
98 %18 = llvm.extractvalue %17[0] : !llvm.struct<(i32, f64, i32)>
99 %19 = llvm.insertvalue %18, %17[2] : !llvm.struct<(i32, f64, i32)>
100 %20 = llvm.mlir.addressof @foo : !llvm.ptr
101 %21 = llvm.call %20(%arg0) : !llvm.ptr, (i32) -> !llvm.struct<(i32, f64, i32)>
104 // CHECK: llvm.call @vararg_func(%arg0, %arg0) vararg(!llvm.func<void (i32, ...)>) : (i32, i32) -> ()
105 // CHECK: llvm.call @vararg_func(%arg0, %arg0) vararg(!llvm.func<void (i32, ...)>) {fastmathFlags = #llvm.fastmath<fast>} : (i32, i32) -> ()
106 // CHECK: %[[VARIADIC_FUNC:.*]] = llvm.mlir.addressof @vararg_func : !llvm.ptr
107 // CHECK: llvm.call %[[VARIADIC_FUNC]](%[[I32]], %[[I32]]) vararg(!llvm.func<void (i32, ...)>) : !llvm.ptr, (i32, i32) -> ()
108 // CHECK: llvm.call %[[VARIADIC_FUNC]](%[[I32]], %[[I32]]) vararg(!llvm.func<void (i32, ...)>) {fastmathFlags = #llvm.fastmath<fast>} : !llvm.ptr, (i32, i32) -> ()
109 llvm.call @vararg_func(%arg0, %arg0) vararg(!llvm.func<void (i32, ...)>) : (i32, i32) -> ()
110 llvm.call @vararg_func(%arg0, %arg0) vararg(!llvm.func<void (i32, ...)>) {fastmathFlags = #llvm.fastmath<fast>} : (i32, i32) -> ()
111 %variadic_func = llvm.mlir.addressof @vararg_func : !llvm.ptr
112 llvm.call %variadic_func(%arg0, %arg0) vararg(!llvm.func<void (i32, ...)>) : !llvm.ptr, (i32, i32) -> ()
113 llvm.call %variadic_func(%arg0, %arg0) vararg(!llvm.func<void (i32, ...)>) {fastmathFlags = #llvm.fastmath<fast>} : !llvm.ptr, (i32, i32) -> ()
115 // Function call attributes
116 // CHECK: llvm.call @baz() {convergent} : () -> ()
117 llvm.call @baz() {convergent} : () -> ()
119 // CHECK: llvm.call @baz() {no_unwind} : () -> ()
120 llvm.call @baz() {no_unwind} : () -> ()
122 // CHECK: llvm.call @baz() {will_return} : () -> ()
123 llvm.call @baz() {will_return} : () -> ()
125 // CHECK: llvm.call @baz() {memory = #llvm.memory_effects<other = none, argMem = read, inaccessibleMem = write>} : () -> ()
126 llvm.call @baz() {memory = #llvm.memory_effects<other = none, argMem = read, inaccessibleMem = write>} : () -> ()
128 // Terminator operations and their successors.
130 // CHECK: llvm.br ^[[BB1:.*]]
135 // CHECK: llvm.cond_br %7, ^[[BB2:.*]], ^[[BB3:.*]]
136 llvm.cond_br %7, ^bb2, ^bb3
140 // CHECK: %{{.*}} = llvm.mlir.undef : !llvm.struct<(i32, f64, i32)>
141 // CHECK: %{{.*}} = llvm.mlir.constant(42 : i64) : i47
142 %22 = llvm.mlir.undef : !llvm.struct<(i32, f64, i32)>
143 %23 = llvm.mlir.constant(42) : i47
144 // CHECK: llvm.switch %0 : i32, ^[[BB3]] [
145 // CHECK-NEXT: 1: ^[[BB4:.*]],
146 // CHECK-NEXT: 2: ^[[BB5:.*]],
147 // CHECK-NEXT: 3: ^[[BB6:.*]]
149 llvm.switch %0 : i32, ^bb3 [
157 // CHECK: llvm.switch %0 : i32, ^[[BB7:.*]] [
159 llvm.switch %0 : i32, ^bb7 [
164 llvm.switch %0 : i32, ^bb7 [
169 llvm.switch %0 : i32, ^bb7 [
174 llvm.switch %0 : i32, ^bb7 [
180 // CHECK: %{{.*}} = llvm.select %{{.*}}, %{{.*}}, %{{.*}} : i1, i32
181 %24 = llvm.select %7, %0, %1 : i1, i32
183 // Integer to pointer and pointer to integer conversions.
185 // CHECK: %[[PTR:.*]] = llvm.inttoptr %[[I32]] : i32 to !llvm.ptr
186 // CHECK: %{{.*}} = llvm.ptrtoint %[[PTR]] : !llvm.ptr to i32
187 %25 = llvm.inttoptr %arg0 : i32 to !llvm.ptr
188 %26 = llvm.ptrtoint %25 : !llvm.ptr to i32
190 // Extended and Quad floating point
192 // CHECK: %{{.*}} = llvm.fpext %[[FLOAT]] : f32 to f80
193 // CHECK: %{{.*}} = llvm.fpext %[[FLOAT]] : f32 to f128
194 %27 = llvm.fpext %arg1 : f32 to f80
195 %28 = llvm.fpext %arg1 : f32 to f128
197 // CHECK: %{{.*}} = llvm.fneg %[[FLOAT]] : f32
198 %29 = llvm.fneg %arg1 : f32
200 // CHECK: llvm.intr.sin(%[[FLOAT]]) : (f32) -> f32
201 %30 = llvm.intr.sin(%arg1) : (f32) -> f32
203 // CHECK: llvm.intr.pow(%[[FLOAT]], %[[FLOAT]]) : (f32, f32) -> f32
204 %31 = llvm.intr.pow(%arg1, %arg1) : (f32, f32) -> f32
206 // CHECK: llvm.intr.powi(%[[FLOAT]], %[[I32]]) : (f32, i32) -> f32
207 %a31 = llvm.intr.powi(%arg1, %arg0) : (f32, i32) -> f32
209 // CHECK: llvm.intr.bitreverse(%{{.*}}) : (i32) -> i32
210 %32 = llvm.intr.bitreverse(%arg0) : (i32) -> i32
212 // CHECK: llvm.intr.ctpop(%{{.*}}) : (i32) -> i32
213 %33 = llvm.intr.ctpop(%arg0) : (i32) -> i32
215 // CHECK: llvm.intr.round(%[[FLOAT]]) : (f32) -> f32
216 %34 = llvm.intr.round(%arg1) : (f32) -> f32
218 // CHECK: "llvm.intr.memcpy"(%{{.*}}, %{{.*}}, %{{.*}}) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()
219 "llvm.intr.memcpy"(%arg2, %arg3, %arg0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()
221 // CHECK: "llvm.intr.memcpy"(%{{.*}}, %{{.*}}, %{{.*}}) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()
222 "llvm.intr.memcpy"(%arg2, %arg3, %arg0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()
224 // CHECK: "llvm.intr.memcpy.inline"(%{{.*}}, %{{.*}}) <{isVolatile = false, len = 10 : i64}> : (!llvm.ptr, !llvm.ptr) -> ()
225 "llvm.intr.memcpy.inline"(%arg2, %arg3) <{isVolatile = false, len = 10 : i64}> : (!llvm.ptr, !llvm.ptr) -> ()
227 // CHECK: llvm.return
232 llvm.func @gep(%ptr: !llvm.ptr, %idx: i64, %ptr2: !llvm.ptr) {
233 // CHECK: llvm.getelementptr %{{.*}}[%{{.*}}, 1, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i32, struct<(i32, f32)>)>
234 llvm.getelementptr %ptr[%idx, 1, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(i32, struct<(i32, f32)>)>
235 // CHECK: llvm.getelementptr inbounds %{{.*}}[%{{.*}}, 0, %{{.*}}] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<(array<10 x f32>)>
236 llvm.getelementptr inbounds %ptr2[%idx, 0, %idx] : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.struct<(array<10 x f32>)>
240 llvm.func @vararg_foo(i32, ...) -> !llvm.struct<(i32, f64, i32)>
242 // An larger self-contained function.
243 // CHECK-LABEL: llvm.func @foo(%{{.*}}: i32) -> !llvm.struct<(i32, f64, i32)> {
244 llvm.func @foo(%arg0: i32) -> !llvm.struct<(i32, f64, i32)> {
245 // CHECK: %[[V0:.*]] = llvm.mlir.constant(3 : i64) : i32
246 // CHECK: %[[V1:.*]] = llvm.mlir.constant(3 : i64) : i32
247 // CHECK: %[[V2:.*]] = llvm.mlir.constant(4.200000e+01 : f64) : f64
248 // CHECK: %[[V3:.*]] = llvm.mlir.constant(4.200000e+01 : f64) : f64
249 // CHECK: %[[V4:.*]] = llvm.add %[[V0]], %[[V1]] : i32
250 // CHECK: %[[V5:.*]] = llvm.mul %[[V4]], %[[V1]] : i32
251 // CHECK: %[[V6:.*]] = llvm.fadd %[[V2]], %[[V3]] : f64
252 // CHECK: %[[V7:.*]] = llvm.fsub %[[V3]], %[[V6]] : f64
253 // CHECK: %[[V8:.*]] = llvm.mlir.constant(1 : i64) : i1
254 // CHECK: llvm.cond_br %[[V8]], ^[[BB1:.*]](%[[V4]] : i32), ^[[BB2:.*]](%[[V4]] : i32)
255 %0 = llvm.mlir.constant(3) : i32
256 %1 = llvm.mlir.constant(3) : i32
257 %2 = llvm.mlir.constant(4.200000e+01) : f64
258 %3 = llvm.mlir.constant(4.200000e+01) : f64
259 %4 = llvm.add %0, %1 : i32
260 %5 = llvm.mul %4, %1 : i32
261 %6 = llvm.fadd %2, %3 : f64
262 %7 = llvm.fsub %3, %6 : f64
263 %8 = llvm.mlir.constant(1) : i1
264 llvm.cond_br %8, ^bb1(%4 : i32), ^bb2(%4 : i32)
266 // CHECK:^[[BB1]](%[[V9:.*]]: i32):
267 // CHECK: %[[V10:.*]] = llvm.call @foo(%[[V9]]) : (i32) -> !llvm.struct<(i32, f64, i32)>
268 // CHECK: %[[V11:.*]] = llvm.extractvalue %[[V10]][0] : !llvm.struct<(i32, f64, i32)>
269 // CHECK: %[[V12:.*]] = llvm.extractvalue %[[V10]][1] : !llvm.struct<(i32, f64, i32)>
270 // CHECK: %[[V13:.*]] = llvm.extractvalue %[[V10]][2] : !llvm.struct<(i32, f64, i32)>
271 // CHECK: %[[V14:.*]] = llvm.mlir.undef : !llvm.struct<(i32, f64, i32)>
272 // CHECK: %[[V15:.*]] = llvm.insertvalue %[[V5]], %[[V14]][0] : !llvm.struct<(i32, f64, i32)>
273 // CHECK: %[[V16:.*]] = llvm.insertvalue %[[V7]], %[[V15]][1] : !llvm.struct<(i32, f64, i32)>
274 // CHECK: %[[V17:.*]] = llvm.insertvalue %[[V11]], %[[V16]][2] : !llvm.struct<(i32, f64, i32)>
275 // CHECK: llvm.return %[[V17]] : !llvm.struct<(i32, f64, i32)>
277 %10 = llvm.call @foo(%9) : (i32) -> !llvm.struct<(i32, f64, i32)>
278 %11 = llvm.extractvalue %10[0] : !llvm.struct<(i32, f64, i32)>
279 %12 = llvm.extractvalue %10[1] : !llvm.struct<(i32, f64, i32)>
280 %13 = llvm.extractvalue %10[2] : !llvm.struct<(i32, f64, i32)>
281 %14 = llvm.mlir.undef : !llvm.struct<(i32, f64, i32)>
282 %15 = llvm.insertvalue %5, %14[0] : !llvm.struct<(i32, f64, i32)>
283 %16 = llvm.insertvalue %7, %15[1] : !llvm.struct<(i32, f64, i32)>
284 %17 = llvm.insertvalue %11, %16[2] : !llvm.struct<(i32, f64, i32)>
285 llvm.return %17 : !llvm.struct<(i32, f64, i32)>
287 // CHECK:^[[BB2]](%[[V18:.*]]: i32):
288 // CHECK: %[[V19:.*]] = llvm.mlir.undef : !llvm.struct<(i32, f64, i32)>
289 // CHECK: %[[V20:.*]] = llvm.insertvalue %[[V18]], %[[V19]][0] : !llvm.struct<(i32, f64, i32)>
290 // CHECK: %[[V21:.*]] = llvm.insertvalue %[[V7]], %[[V20]][1] : !llvm.struct<(i32, f64, i32)>
291 // CHECK: %[[V22:.*]] = llvm.insertvalue %[[V5]], %[[V21]][2] : !llvm.struct<(i32, f64, i32)>
292 // CHECK: llvm.return %[[V22]] : !llvm.struct<(i32, f64, i32)>
294 %19 = llvm.mlir.undef : !llvm.struct<(i32, f64, i32)>
295 %20 = llvm.insertvalue %18, %19[0] : !llvm.struct<(i32, f64, i32)>
296 %21 = llvm.insertvalue %7, %20[1] : !llvm.struct<(i32, f64, i32)>
297 %22 = llvm.insertvalue %5, %21[2] : !llvm.struct<(i32, f64, i32)>
298 llvm.return %22 : !llvm.struct<(i32, f64, i32)>
301 // CHECK-LABEL: @casts
302 // CHECK-SAME: (%[[I32:.*]]: i32, %[[I64:.*]]: i64, %[[V4I32:.*]]: vector<4xi32>, %[[V4I64:.*]]: vector<4xi64>, %[[PTR:.*]]: !llvm.ptr)
303 func.func @casts(%arg0: i32, %arg1: i64, %arg2: vector<4xi32>,
304 %arg3: vector<4xi64>, %arg4: !llvm.ptr) {
305 // CHECK: = llvm.sext %[[I32]] : i32 to i56
306 %0 = llvm.sext %arg0 : i32 to i56
307 // CHECK: = llvm.zext %[[I32]] : i32 to i64
308 %1 = llvm.zext %arg0 : i32 to i64
309 // CHECK: = llvm.trunc %[[I64]] : i64 to i56
310 %2 = llvm.trunc %arg1 : i64 to i56
311 // CHECK: = llvm.sext %[[V4I32]] : vector<4xi32> to vector<4xi56>
312 %3 = llvm.sext %arg2 : vector<4xi32> to vector<4xi56>
313 // CHECK: = llvm.zext %[[V4I32]] : vector<4xi32> to vector<4xi64>
314 %4 = llvm.zext %arg2 : vector<4xi32> to vector<4xi64>
315 // CHECK: = llvm.trunc %[[V4I64]] : vector<4xi64> to vector<4xi56>
316 %5 = llvm.trunc %arg3 : vector<4xi64> to vector<4xi56>
317 // CHECK: = llvm.sitofp %[[I32]] : i32 to f32
318 %6 = llvm.sitofp %arg0 : i32 to f32
319 // CHECK: %[[FLOAT:.*]] = llvm.uitofp %[[I32]] : i32 to f32
320 %7 = llvm.uitofp %arg0 : i32 to f32
321 // CHECK: = llvm.fptosi %[[FLOAT]] : f32 to i32
322 %8 = llvm.fptosi %7 : f32 to i32
323 // CHECK: = llvm.fptoui %[[FLOAT]] : f32 to i32
324 %9 = llvm.fptoui %7 : f32 to i32
325 // CHECK: = llvm.addrspacecast %[[PTR]] : !llvm.ptr to !llvm.ptr<2>
326 %10 = llvm.addrspacecast %arg4 : !llvm.ptr to !llvm.ptr<2>
327 // CHECK: = llvm.bitcast %[[I64]] : i64 to f64
328 %11 = llvm.bitcast %arg1 : i64 to f64
332 // CHECK-LABEL: @nneg_casts
333 // CHECK-SAME: (%[[I32:.*]]: i32, %[[I64:.*]]: i64, %[[V4I32:.*]]: vector<4xi32>, %[[V4I64:.*]]: vector<4xi64>, %[[PTR:.*]]: !llvm.ptr)
334 func.func @nneg_casts(%arg0: i32, %arg1: i64, %arg2: vector<4xi32>,
335 %arg3: vector<4xi64>, %arg4: !llvm.ptr) {
336 // CHECK: = llvm.zext nneg %[[I32]] : i32 to i64
337 %0 = llvm.zext nneg %arg0 : i32 to i64
338 // CHECK: = llvm.zext nneg %[[V4I32]] : vector<4xi32> to vector<4xi64>
339 %4 = llvm.zext nneg %arg2 : vector<4xi32> to vector<4xi64>
340 // CHECK: = llvm.uitofp nneg %[[I32]] : i32 to f32
341 %7 = llvm.uitofp nneg %arg0 : i32 to f32
345 // CHECK-LABEL: @casts_overflow
346 // CHECK-SAME: (%[[I32:.*]]: i32, %[[I64:.*]]: i64, %[[V4I32:.*]]: vector<4xi32>, %[[V4I64:.*]]: vector<4xi64>, %[[PTR:.*]]: !llvm.ptr)
347 func.func @casts_overflow(%arg0: i32, %arg1: i64, %arg2: vector<4xi32>,
348 %arg3: vector<4xi64>, %arg4: !llvm.ptr) {
349 // CHECK: = llvm.trunc %[[I64]] overflow<nsw> : i64 to i56
350 %0 = llvm.trunc %arg1 overflow<nsw> : i64 to i56
351 // CHECK: = llvm.trunc %[[I64]] overflow<nuw> : i64 to i56
352 %1 = llvm.trunc %arg1 overflow<nuw> : i64 to i56
353 // CHECK: = llvm.trunc %[[I64]] overflow<nsw, nuw> : i64 to i56
354 %2 = llvm.trunc %arg1 overflow<nsw, nuw> : i64 to i56
355 // CHECK: = llvm.trunc %[[I64]] overflow<nsw, nuw> : i64 to i56
356 %3 = llvm.trunc %arg1 overflow<nuw, nsw> : i64 to i56
357 // CHECK: = llvm.trunc %[[V4I64]] overflow<nsw> : vector<4xi64> to vector<4xi56>
358 %4 = llvm.trunc %arg3 overflow<nsw> : vector<4xi64> to vector<4xi56>
362 // CHECK-LABEL: @vect
363 func.func @vect(%arg0: vector<4xf32>, %arg1: i32, %arg2: f32, %arg3: !llvm.vec<2 x ptr>) {
364 // CHECK: = llvm.extractelement {{.*}} : vector<4xf32>
365 %0 = llvm.extractelement %arg0[%arg1 : i32] : vector<4xf32>
366 // CHECK: = llvm.insertelement {{.*}} : vector<4xf32>
367 %1 = llvm.insertelement %arg2, %arg0[%arg1 : i32] : vector<4xf32>
368 // CHECK: = llvm.shufflevector {{.*}} [0, 0, 0, 0, 7] : vector<4xf32>
369 %2 = llvm.shufflevector %arg0, %arg0 [0, 0, 0, 0, 7] : vector<4xf32>
370 // CHECK: = llvm.shufflevector %{{.+}}, %{{.+}} [1, 0] : !llvm.vec<2 x ptr>
371 %3 = llvm.shufflevector %arg3, %arg3 [1, 0] : !llvm.vec<2 x ptr>
372 // CHECK: = llvm.mlir.constant(dense<1.000000e+00> : vector<4xf32>) : vector<4xf32>
373 %4 = llvm.mlir.constant(dense<1.0> : vector<4xf32>) : vector<4xf32>
377 // CHECK-LABEL: @scalable_vect
378 func.func @scalable_vect(%arg0: vector<[4]xf32>, %arg1: i32, %arg2: f32) {
379 // CHECK: = llvm.extractelement {{.*}} : vector<[4]xf32>
380 %0 = llvm.extractelement %arg0[%arg1 : i32] : vector<[4]xf32>
381 // CHECK: = llvm.insertelement {{.*}} : vector<[4]xf32>
382 %1 = llvm.insertelement %arg2, %arg0[%arg1 : i32] : vector<[4]xf32>
383 // CHECK: = llvm.shufflevector {{.*}} [0, 0, 0, 0] : vector<[4]xf32>
384 %2 = llvm.shufflevector %arg0, %arg0 [0, 0, 0, 0] : vector<[4]xf32>
385 // CHECK: = llvm.mlir.constant(dense<1.000000e+00> : vector<[4]xf32>) : vector<[4]xf32>
386 %3 = llvm.mlir.constant(dense<1.0> : vector<[4]xf32>) : vector<[4]xf32>
390 // CHECK-LABEL: @mixed_vect
391 func.func @mixed_vect(%arg0: vector<8xf32>, %arg1: vector<4xf32>, %arg2: vector<[4]xf32>) {
392 // CHECK: = llvm.intr.vector.insert {{.*}} : vector<8xf32> into vector<[4]xf32>
393 %0 = llvm.intr.vector.insert %arg0, %arg2[0] : vector<8xf32> into vector<[4]xf32>
394 // CHECK: = llvm.intr.vector.insert {{.*}} : vector<4xf32> into vector<[4]xf32>
395 %1 = llvm.intr.vector.insert %arg1, %arg2[0] : vector<4xf32> into vector<[4]xf32>
396 // CHECK: = llvm.intr.vector.insert {{.*}} : vector<4xf32> into vector<[4]xf32>
397 %2 = llvm.intr.vector.insert %arg1, %1[4] : vector<4xf32> into vector<[4]xf32>
398 // CHECK: = llvm.intr.vector.insert {{.*}} : vector<4xf32> into vector<8xf32>
399 %3 = llvm.intr.vector.insert %arg1, %arg0[4] : vector<4xf32> into vector<8xf32>
400 // CHECK: = llvm.intr.vector.extract {{.*}} : vector<8xf32> from vector<[4]xf32>
401 %4 = llvm.intr.vector.extract %2[0] : vector<8xf32> from vector<[4]xf32>
402 // CHECK: = llvm.intr.vector.extract {{.*}} : vector<2xf32> from vector<8xf32>
403 %5 = llvm.intr.vector.extract %arg0[6] : vector<2xf32> from vector<8xf32>
407 // CHECK-LABEL: @vector_interleave2
408 func.func @vector_interleave2(%vec1: vector<[4]xf16>, %vec2 : vector<[4]xf16>) {
409 // CHECK: = "llvm.intr.vector.interleave2"({{.*}}) : (vector<[4]xf16>, vector<[4]xf16>) -> vector<[8]xf16>
410 %0 = "llvm.intr.vector.interleave2"(%vec1, %vec2) : (vector<[4]xf16>, vector<[4]xf16>) -> vector<[8]xf16>
414 // CHECK-LABEL: @vector_deinterleave2
415 func.func @vector_deinterleave2(%vec: vector<[8]xf16>) {
416 // CHECK: = "llvm.intr.vector.deinterleave2"({{.*}}) : (vector<[8]xf16>) -> !llvm.struct<(vector<[4]xf16>, vector<[4]xf16>)>
417 %0 = "llvm.intr.vector.deinterleave2"(%vec) : (vector<[8]xf16>) -> !llvm.struct<(vector<[4]xf16>, vector<[4]xf16>)>
421 // CHECK-LABEL: @alloca
422 func.func @alloca(%size : i64) {
423 // CHECK: llvm.alloca %{{.*}} x i32 : (i64) -> !llvm.ptr
424 llvm.alloca %size x i32 {alignment = 0} : (i64) -> (!llvm.ptr)
425 // CHECK: llvm.alloca inalloca %{{.*}} x i32 {alignment = 8 : i64} : (i64) -> !llvm.ptr
426 llvm.alloca inalloca %size x i32 {alignment = 8} : (i64) -> (!llvm.ptr)
430 // CHECK-LABEL: @null
432 // CHECK: llvm.mlir.zero : !llvm.ptr
433 %0 = llvm.mlir.zero : !llvm.ptr
437 // CHECK-LABEL: @zero
439 // CHECK: llvm.mlir.zero : i8
440 %0 = llvm.mlir.zero : i8
444 // CHECK-LABEL: @atomic_load
445 func.func @atomic_load(%ptr : !llvm.ptr) {
446 // CHECK: llvm.load %{{.*}} atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> f32
447 %0 = llvm.load %ptr atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> f32
448 // CHECK: llvm.load volatile %{{.*}} atomic syncscope("singlethread") monotonic {alignment = 16 : i64} : !llvm.ptr -> f32
449 %1 = llvm.load volatile %ptr atomic syncscope("singlethread") monotonic {alignment = 16 : i64} : !llvm.ptr -> f32
450 // CHECK: llvm.load %{{.*}} atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> i128
451 %2 = llvm.load %ptr atomic monotonic {alignment = 4 : i64} : !llvm.ptr -> i128
455 // CHECK-LABEL: @atomic_store
456 func.func @atomic_store(%val : f32, %large_val : i256, %ptr : !llvm.ptr) {
457 // CHECK: llvm.store %{{.*}}, %{{.*}} atomic monotonic {alignment = 4 : i64} : f32, !llvm.ptr
458 llvm.store %val, %ptr atomic monotonic {alignment = 4 : i64} : f32, !llvm.ptr
459 // CHECK: llvm.store volatile %{{.*}}, %{{.*}} atomic syncscope("singlethread") monotonic {alignment = 16 : i64} : f32, !llvm.ptr
460 llvm.store volatile %val, %ptr atomic syncscope("singlethread") monotonic {alignment = 16 : i64} : f32, !llvm.ptr
461 // CHECK: llvm.store %{{.*}}, %{{.*}} atomic monotonic {alignment = 4 : i64} : i256, !llvm.ptr
462 llvm.store %large_val, %ptr atomic monotonic {alignment = 4 : i64} : i256, !llvm.ptr
466 // CHECK-LABEL: @atomicrmw
467 func.func @atomicrmw(%ptr : !llvm.ptr, %f32 : f32, %f16_vec : vector<2xf16>) {
468 // CHECK: llvm.atomicrmw fadd %{{.*}}, %{{.*}} monotonic : !llvm.ptr, f32
469 %0 = llvm.atomicrmw fadd %ptr, %f32 monotonic : !llvm.ptr, f32
470 // CHECK: llvm.atomicrmw volatile fsub %{{.*}}, %{{.*}} syncscope("singlethread") monotonic {alignment = 16 : i64} : !llvm.ptr, f32
471 %1 = llvm.atomicrmw volatile fsub %ptr, %f32 syncscope("singlethread") monotonic {alignment = 16 : i64} : !llvm.ptr, f32
472 // CHECK: llvm.atomicrmw fmin %{{.*}}, %{{.*}} monotonic : !llvm.ptr, vector<2xf16>
473 %2 = llvm.atomicrmw fmin %ptr, %f16_vec monotonic : !llvm.ptr, vector<2xf16>
477 // CHECK-LABEL: @cmpxchg
478 func.func @cmpxchg(%ptr : !llvm.ptr, %cmp : i32, %new : i32) {
479 // CHECK: llvm.cmpxchg %{{.*}}, %{{.*}}, %{{.*}} acq_rel monotonic : !llvm.ptr, i32
480 %0 = llvm.cmpxchg %ptr, %cmp, %new acq_rel monotonic : !llvm.ptr, i32
481 // CHECK: llvm.cmpxchg weak volatile %{{.*}}, %{{.*}}, %{{.*}} syncscope("singlethread") acq_rel monotonic {alignment = 16 : i64} : !llvm.ptr, i32
482 %1 = llvm.cmpxchg weak volatile %ptr, %cmp, %new syncscope("singlethread") acq_rel monotonic {alignment = 16 : i64} : !llvm.ptr, i32
486 // CHECK-LABEL: @invariant_load
487 func.func @invariant_load(%ptr : !llvm.ptr) -> i32 {
488 // CHECK: llvm.load %{{.+}} invariant {alignment = 4 : i64} : !llvm.ptr -> i32
489 %0 = llvm.load %ptr invariant {alignment = 4 : i64} : !llvm.ptr -> i32
493 // CHECK-LABEL: @invariant_group_load
494 func.func @invariant_group_load(%ptr : !llvm.ptr) -> i32 {
495 // CHECK: llvm.load %{{.+}} invariant_group {alignment = 4 : i64} : !llvm.ptr -> i32
496 %0 = llvm.load %ptr invariant_group {alignment = 4 : i64} : !llvm.ptr -> i32
500 // CHECK-LABEL: @invariant_group_store
501 func.func @invariant_group_store(%val: i32, %ptr : !llvm.ptr) {
502 // CHECK: llvm.store %{{.+}}, %{{.+}} invariant_group : i32, !llvm.ptr
503 llvm.store %val, %ptr invariant_group : i32, !llvm.ptr
507 llvm.mlir.global external constant @_ZTIi() : !llvm.ptr
508 llvm.func @bar(!llvm.ptr, !llvm.ptr, !llvm.ptr)
509 llvm.func @__gxx_personality_v0(...) -> i32
511 // CHECK-LABEL: @invokeLandingpad
512 llvm.func @invokeLandingpad() -> i32 attributes { personality = @__gxx_personality_v0 } {
513 // CHECK: %[[V0:.*]] = llvm.mlir.constant(0 : i32) : i32
514 // CHECK: %{{.*}} = llvm.mlir.constant(3 : i32) : i32
515 // CHECK: %[[V1:.*]] = llvm.mlir.constant("\01") : !llvm.array<1 x i8>
516 // CHECK: %[[V2:.*]] = llvm.mlir.zero : !llvm.ptr
517 // CHECK: %[[V3:.*]] = llvm.mlir.addressof @_ZTIi : !llvm.ptr
518 // CHECK: %[[V4:.*]] = llvm.mlir.constant(1 : i32) : i32
519 // CHECK: %[[V5:.*]] = llvm.alloca %[[V4]] x i8 : (i32) -> !llvm.ptr
520 // CHECK: %{{.*}} = llvm.invoke @foo(%[[V4]]) to ^[[BB2:.*]] unwind ^[[BB1:.*]] : (i32) -> !llvm.struct<(i32, f64, i32)>
521 %0 = llvm.mlir.constant(0 : i32) : i32
522 %1 = llvm.mlir.constant(3 : i32) : i32
523 %2 = llvm.mlir.constant("\01") : !llvm.array<1 x i8>
524 %3 = llvm.mlir.zero : !llvm.ptr
525 %4 = llvm.mlir.addressof @_ZTIi : !llvm.ptr
526 %5 = llvm.mlir.constant(1 : i32) : i32
527 %6 = llvm.alloca %5 x i8 : (i32) -> !llvm.ptr
528 %7 = llvm.invoke @foo(%5) to ^bb2 unwind ^bb1 : (i32) -> !llvm.struct<(i32, f64, i32)>
531 // CHECK: %[[lp:.*]] = llvm.landingpad cleanup (catch %[[V2]] : !llvm.ptr) (catch %[[V3]] : !llvm.ptr) (filter %[[V1]] : !llvm.array<1 x i8>) : !llvm.struct<(ptr, i32)>
532 // CHECK: %{{.*}} = llvm.intr.eh.typeid.for %[[V3]] : (!llvm.ptr) -> i32
533 // CHECK: llvm.resume %[[lp]] : !llvm.struct<(ptr, i32)>
535 %10 = llvm.landingpad cleanup (catch %3 : !llvm.ptr) (catch %4 : !llvm.ptr) (filter %2 : !llvm.array<1 x i8>) : !llvm.struct<(ptr, i32)>
536 %11 = llvm.intr.eh.typeid.for %4 : (!llvm.ptr) -> i32
537 llvm.resume %10 : !llvm.struct<(ptr, i32)>
540 // CHECK: llvm.return %[[V4]] : i32
544 // CHECK: ^[[BB3:.*]]:
545 // CHECK: llvm.invoke @bar(%[[V5]], %[[V3]], %[[V2]]) to ^[[BB2]] unwind ^[[BB1]] : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
547 llvm.invoke @bar(%6, %4, %3) to ^bb2 unwind ^bb1 : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
549 // CHECK: ^[[BB4:.*]]:
550 // CHECK: %[[FUNC:.*]] = llvm.mlir.addressof @foo : !llvm.ptr
551 // CHECK: %{{.*}} = llvm.invoke %[[FUNC]]{{.*}}: !llvm.ptr,
553 %12 = llvm.mlir.addressof @foo : !llvm.ptr
554 %13 = llvm.invoke %12(%5) to ^bb2 unwind ^bb1 : !llvm.ptr, (i32) -> !llvm.struct<(i32, f64, i32)>
556 // CHECK: ^[[BB5:.*]]:
557 // CHECK: %{{.*}} = llvm.invoke @{{.*}} vararg(!llvm.func<struct<(i32, f64, i32)> (i32, ...)>) : (i32, i32) -> !llvm.struct<(i32, f64, i32)>
560 %14 = llvm.invoke @vararg_foo(%5, %5) to ^bb2 unwind ^bb1 vararg(!llvm.func<struct<(i32, f64, i32)> (i32, ...)>) : (i32, i32) -> !llvm.struct<(i32, f64, i32)>
562 // CHECK: ^[[BB6:.*]]:
563 // CHECK: %[[FUNC:.*]] = llvm.mlir.addressof @vararg_foo : !llvm.ptr
564 // CHECK: %{{.*}} = llvm.invoke %[[FUNC]]{{.*}} vararg(!llvm.func<struct<(i32, f64, i32)> (i32, ...)>) : !llvm.ptr, (i32, i32) -> !llvm.struct<(i32, f64, i32)>
566 %15 = llvm.mlir.addressof @vararg_foo : !llvm.ptr
567 %16 = llvm.invoke %15(%5, %5) to ^bb2 unwind ^bb1 vararg(!llvm.func<!llvm.struct<(i32, f64, i32)> (i32, ...)>) : !llvm.ptr, (i32, i32) -> !llvm.struct<(i32, f64, i32)>
569 // CHECK: ^[[BB7:.*]]:
570 // CHECK: llvm.return %[[V0]] : i32
575 // CHECK-LABEL: @useFreezeOp
576 func.func @useFreezeOp(%arg0: i32) {
577 // CHECK: = llvm.freeze %[[ARG0:.*]] : i32
578 %0 = llvm.freeze %arg0 : i32
579 // CHECK: %[[UNDEF:.*]] = llvm.mlir.undef : i8
580 %1 = llvm.mlir.undef : i8
581 // CHECK: = llvm.freeze %[[UNDEF]] : i8
582 %2 = llvm.freeze %1 : i8
583 // CHECK: %[[POISON:.*]] = llvm.mlir.poison : i8
584 %3 = llvm.mlir.poison : i8
585 // CHECK: = llvm.freeze %[[POISON]] : i8
586 %4 = llvm.freeze %3 : i8
590 // CHECK-LABEL: @useFenceInst
591 func.func @useFenceInst() {
592 // CHECK: syncscope("agent") seq_cst
593 llvm.fence syncscope("agent") seq_cst
595 llvm.fence syncscope("") seq_cst
601 // CHECK-LABEL: @useInlineAsm
602 llvm.func @useInlineAsm(%arg0: i32) {
603 // CHECK: llvm.inline_asm {{.*}} (i32) -> i8
604 %0 = llvm.inline_asm "bswap $0", "=r,r" %arg0 : (i32) -> i8
606 // CHECK-NEXT: llvm.inline_asm {{.*}} (i32, i32) -> i8
607 %1 = llvm.inline_asm "foo", "bar" %arg0, %arg0 : (i32, i32) -> i8
609 // CHECK-NEXT: llvm.inline_asm has_side_effects {{.*}} (i32, i32) -> i8
610 %2 = llvm.inline_asm has_side_effects "foo", "bar" %arg0, %arg0 : (i32, i32) -> i8
612 // CHECK-NEXT: llvm.inline_asm is_align_stack {{.*}} (i32, i32) -> i8
613 %3 = llvm.inline_asm is_align_stack "foo", "bar" %arg0, %arg0 : (i32, i32) -> i8
615 // CHECK-NEXT: llvm.inline_asm "foo", "=r,=r,r" {{.*}} : (i32) -> !llvm.struct<(i8, i8)>
616 %5 = llvm.inline_asm "foo", "=r,=r,r" %arg0 : (i32) -> !llvm.struct<(i8, i8)>
621 // CHECK-LABEL: @fastmathFlags
622 func.func @fastmathFlags(%arg0: f32, %arg1: f32, %arg2: i32, %arg3: vector<2 x f32>, %arg4: vector<2 x f32>) {
623 // CHECK: {{.*}} = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
624 // CHECK: {{.*}} = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
625 // CHECK: {{.*}} = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
626 // CHECK: {{.*}} = llvm.fdiv %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
627 // CHECK: {{.*}} = llvm.frem %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
628 %0 = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
629 %1 = llvm.fsub %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
630 %2 = llvm.fmul %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
631 %3 = llvm.fdiv %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
632 %4 = llvm.frem %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
634 // CHECK: %[[SCALAR_PRED0:.+]] = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
635 %5 = llvm.fcmp "oeq" %arg0, %arg1 {fastmathFlags = #llvm.fastmath<fast>} : f32
636 // CHECK: %{{.*}} = llvm.add %[[SCALAR_PRED0]], %[[SCALAR_PRED0]] : i1
637 %typecheck_5 = llvm.add %5, %5 : i1
638 // CHECK: %[[VEC_PRED0:.+]] = llvm.fcmp "oeq" %arg3, %arg4 {fastmathFlags = #llvm.fastmath<fast>} : vector<2xf32>
639 %vcmp = llvm.fcmp "oeq" %arg3, %arg4 {fastmathFlags = #llvm.fastmath<fast>} : vector<2xf32>
640 // CHECK: %{{.*}} = llvm.add %[[VEC_PRED0]], %[[VEC_PRED0]] : vector<2xi1>
641 %typecheck_vcmp = llvm.add %vcmp, %vcmp : vector<2xi1>
643 // CHECK: {{.*}} = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath<fast>} : f32
644 %6 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath<fast>} : f32
646 // CHECK: {{.*}} = llvm.call @foo(%arg2) {fastmathFlags = #llvm.fastmath<fast>} : (i32) -> !llvm.struct<(i32, f64, i32)>
647 %7 = llvm.call @foo(%arg2) {fastmathFlags = #llvm.fastmath<fast>} : (i32) -> !llvm.struct<(i32, f64, i32)>
649 // CHECK: {{.*}} = llvm.fadd %arg0, %arg1 : f32
650 %8 = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath<none>} : f32
651 // CHECK: {{.*}} = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath<nnan, ninf>} : f32
652 %9 = llvm.fadd %arg0, %arg1 {fastmathFlags = #llvm.fastmath<nnan,ninf>} : f32
654 // CHECK: {{.*}} = llvm.fneg %arg0 : f32
655 %10 = llvm.fneg %arg0 {fastmathFlags = #llvm.fastmath<none>} : f32
657 // CHECK: {{.*}} = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath<fast>} : (f32) -> f32
658 %11 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath<fast>} : (f32) -> f32
659 // CHECK: {{.*}} = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath<afn>} : (f32) -> f32
660 %12 = llvm.intr.sin(%arg0) {fastmathFlags = #llvm.fastmath<afn>} : (f32) -> f32
662 // CHECK: {{.*}} = llvm.intr.vector.reduce.fmin(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
663 %13 = llvm.intr.vector.reduce.fmin(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
664 // CHECK: {{.*}} = llvm.intr.vector.reduce.fmax(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
665 %14 = llvm.intr.vector.reduce.fmax(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
666 // CHECK: {{.*}} = llvm.intr.vector.reduce.fminimum(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
667 %15 = llvm.intr.vector.reduce.fminimum(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
668 // CHECK: {{.*}} = llvm.intr.vector.reduce.fmaximum(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
669 %16 = llvm.intr.vector.reduce.fmaximum(%arg3) {fastmathFlags = #llvm.fastmath<nnan>} : (vector<2xf32>) -> f32
673 // CHECK-LABEL: @lifetime
674 // CHECK-SAME: %[[P:.*]]: !llvm.ptr
675 llvm.func @lifetime(%p: !llvm.ptr) {
676 // CHECK: llvm.intr.lifetime.start 16, %[[P]]
677 llvm.intr.lifetime.start 16, %p : !llvm.ptr
678 // CHECK: llvm.intr.lifetime.end 16, %[[P]]
679 llvm.intr.lifetime.end 16, %p : !llvm.ptr
683 // CHECK-LABEL: @invariant
684 // CHECK-SAME: %[[P:.*]]: !llvm.ptr
685 llvm.func @invariant(%p: !llvm.ptr) {
686 // CHECK: %[[START:.*]] = llvm.intr.invariant.start 1, %[[P]] : !llvm.ptr
687 %1 = llvm.intr.invariant.start 1, %p : !llvm.ptr
688 // CHECK: llvm.intr.invariant.end %[[START]], 1, %[[P]] : !llvm.ptr
689 llvm.intr.invariant.end %1, 1, %p : !llvm.ptr
693 // CHECK-LABEL: @invariant_group_intrinsics
694 // CHECK-SAME: %[[P:.+]]: !llvm.ptr
695 llvm.func @invariant_group_intrinsics(%p: !llvm.ptr) {
696 // CHECK: %{{.+}} = llvm.intr.launder.invariant.group %[[P]] : !llvm.ptr
697 %1 = llvm.intr.launder.invariant.group %p : !llvm.ptr
698 // CHECK: %{{.+}} = llvm.intr.strip.invariant.group %[[P]] : !llvm.ptr
699 %2 = llvm.intr.strip.invariant.group %p : !llvm.ptr
703 // CHECK-LABEL: @vararg_func
704 llvm.func @vararg_func(%arg0: i32, ...) {
705 // CHECK: %[[C:.*]] = llvm.mlir.constant(1 : i32)
706 // CHECK: %[[LIST:.*]] = llvm.alloca
707 // CHECK: llvm.intr.vastart %[[LIST]] : !llvm.ptr{{$}}
708 %1 = llvm.mlir.constant(1 : i32) : i32
709 %list = llvm.alloca %1 x !llvm.struct<"struct.va_list_opaque", (ptr)> : (i32) -> !llvm.ptr
710 llvm.intr.vastart %list : !llvm.ptr
712 // CHECK: %[[LIST2:.*]] = llvm.alloca
713 // CHECK: llvm.intr.vacopy %[[LIST]] to %[[LIST2]] : !llvm.ptr, !llvm.ptr{{$}}
714 %list2 = llvm.alloca %1 x !llvm.struct<"struct.va_list_opaque", (ptr)> : (i32) -> !llvm.ptr
715 llvm.intr.vacopy %list to %list2 : !llvm.ptr, !llvm.ptr
717 // CHECK: %[[RET:.+]] = llvm.va_arg %[[LIST2]] : (!llvm.ptr) -> i32
718 %ret = llvm.va_arg %list2 : (!llvm.ptr) -> i32
720 // CHECK: llvm.intr.vaend %[[LIST]] : !llvm.ptr{{$}}
721 // CHECK: llvm.intr.vaend %[[LIST2]] : !llvm.ptr{{$}}
722 llvm.intr.vaend %list : !llvm.ptr
723 llvm.intr.vaend %list2 : !llvm.ptr
727 // CHECK-LABEL: @eh_typeid
728 // CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr
729 llvm.func @eh_typeid(%arg0: !llvm.ptr) -> i32 {
730 // CHECK: llvm.intr.eh.typeid.for %[[ARG0]] : (!llvm.ptr) -> i32
731 %0 = llvm.intr.eh.typeid.for %arg0 : (!llvm.ptr) -> i32
735 // CHECK-LABEL: @stackrestore
736 // CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr
737 llvm.func @stackrestore(%arg0: !llvm.ptr) {
738 // CHECK: llvm.intr.stackrestore %[[ARG0]] : !llvm.ptr
739 llvm.intr.stackrestore %arg0 : !llvm.ptr
743 #alias_scope_domain = #llvm.alias_scope_domain<id = distinct[0]<>, description = "The domain">
744 #alias_scope = #llvm.alias_scope<id = distinct[0]<>, domain = #alias_scope_domain, description = "The domain">
746 // CHECK-LABEL: @experimental_noalias_scope_decl
747 llvm.func @experimental_noalias_scope_decl() {
748 // CHECK: llvm.intr.experimental.noalias.scope.decl #{{.*}}
749 llvm.intr.experimental.noalias.scope.decl #alias_scope
753 // CHECK-LABEL: @experimental_constrained_fptrunc
754 llvm.func @experimental_constrained_fptrunc(%in: f64) {
755 // CHECK: llvm.intr.experimental.constrained.fptrunc %{{.*}} towardzero ignore : f64 to f32
756 %0 = llvm.intr.experimental.constrained.fptrunc %in towardzero ignore : f64 to f32
757 // CHECK: llvm.intr.experimental.constrained.fptrunc %{{.*}} tonearest maytrap : f64 to f32
758 %1 = llvm.intr.experimental.constrained.fptrunc %in tonearest maytrap : f64 to f32
759 // CHECK: llvm.intr.experimental.constrained.fptrunc %{{.*}} upward strict : f64 to f32
760 %2 = llvm.intr.experimental.constrained.fptrunc %in upward strict : f64 to f32
761 // CHECK: llvm.intr.experimental.constrained.fptrunc %{{.*}} downward ignore : f64 to f32
762 %3 = llvm.intr.experimental.constrained.fptrunc %in downward ignore : f64 to f32
763 // CHECK: llvm.intr.experimental.constrained.fptrunc %{{.*}} tonearestaway ignore : f64 to f32
764 %4 = llvm.intr.experimental.constrained.fptrunc %in tonearestaway ignore : f64 to f32
768 // CHECK: llvm.func @tail_call_target() -> i32
769 llvm.func @tail_call_target() -> i32
771 // CHECK-LABEL: @test_none
772 llvm.func @test_none() -> i32 {
773 // CHECK-NEXT: llvm.call @tail_call_target() : () -> i32
774 %0 = llvm.call none @tail_call_target() : () -> i32
778 // CHECK-LABEL: @test_default
779 llvm.func @test_default() -> i32 {
780 // CHECK-NEXT: llvm.call @tail_call_target() : () -> i32
781 %0 = llvm.call @tail_call_target() : () -> i32
785 // CHECK-LABEL: @test_musttail
786 llvm.func @test_musttail() -> i32 {
787 // CHECK-NEXT: llvm.call musttail @tail_call_target() : () -> i32
788 %0 = llvm.call musttail @tail_call_target() : () -> i32
792 // CHECK-LABEL: @test_tail
793 llvm.func @test_tail() -> i32 {
794 // CHECK-NEXT: llvm.call tail @tail_call_target() : () -> i32
795 %0 = llvm.call tail @tail_call_target() : () -> i32
799 // CHECK-LABEL: @test_notail
800 llvm.func @test_notail() -> i32 {
801 // CHECK-NEXT: llvm.call notail @tail_call_target() : () -> i32
802 %0 = llvm.call notail @tail_call_target() : () -> i32
806 // CHECK-LABEL: @vector_predication_intrinsics
807 // CHECK-SAME: (%[[ARG0:.*]]: vector<8xi32>, %[[ARG1:.*]]: vector<8xi32>, %[[ARG2:.*]]: vector<8xi1>, %[[ARG3:.*]]: i32)
808 llvm.func @vector_predication_intrinsics(%A: vector<8xi32>, %B: vector<8xi32>,
809 %mask: vector<8xi1>, %evl: i32) {
810 // CHECK-NEXT: "llvm.intr.vp.smax"(%[[ARG0]], %[[ARG1]], %[[ARG2]], %[[ARG3]])
811 "llvm.intr.vp.smax" (%A, %B, %mask, %evl) :
812 (vector<8xi32>, vector<8xi32>, vector<8xi1>, i32) -> vector<8xi32>
813 // CHECK-NEXT: "llvm.intr.vp.smin"(%[[ARG0]], %[[ARG1]], %[[ARG2]], %[[ARG3]])
814 "llvm.intr.vp.smin" (%A, %B, %mask, %evl) :
815 (vector<8xi32>, vector<8xi32>, vector<8xi1>, i32) -> vector<8xi32>
816 // CHECK-NEXT: "llvm.intr.vp.umax"(%[[ARG0]], %[[ARG1]], %[[ARG2]], %[[ARG3]])
817 "llvm.intr.vp.umax" (%A, %B, %mask, %evl) :
818 (vector<8xi32>, vector<8xi32>, vector<8xi1>, i32) -> vector<8xi32>
819 // CHECK-NEXT: "llvm.intr.vp.umin"(%[[ARG0]], %[[ARG1]], %[[ARG2]], %[[ARG3]])
820 "llvm.intr.vp.umin" (%A, %B, %mask, %evl) :
821 (vector<8xi32>, vector<8xi32>, vector<8xi1>, i32) -> vector<8xi32>
825 llvm.func @op_bundle_target()
827 // CHECK-LABEL: @test_call_with_empty_opbundle
828 llvm.func @test_call_with_empty_opbundle() {
829 // CHECK: llvm.call @op_bundle_target() : () -> ()
830 llvm.call @op_bundle_target() [] : () -> ()
834 // CHECK-LABEL: @test_call_with_empty_opbundle_operands
835 llvm.func @test_call_with_empty_opbundle_operands() {
836 // CHECK: llvm.call @op_bundle_target() ["tag"()] : () -> ()
837 llvm.call @op_bundle_target() ["tag"()] : () -> ()
841 // CHECK-LABEL: @test_call_with_opbundle
842 llvm.func @test_call_with_opbundle() {
843 %0 = llvm.mlir.constant(0 : i32) : i32
844 %1 = llvm.mlir.constant(1 : i32) : i32
845 %2 = llvm.mlir.constant(2 : i32) : i32
846 // CHECK: llvm.call @op_bundle_target() ["tag1"(%{{.+}}, %{{.+}} : i32, i32), "tag2"(%{{.+}} : i32)] : () -> ()
847 llvm.call @op_bundle_target() ["tag1"(%0, %1 : i32, i32), "tag2"(%2 : i32)] : () -> ()
851 // CHECK-LABEL: @test_invoke_with_empty_opbundle
852 llvm.func @test_invoke_with_empty_opbundle() attributes { personality = @__gxx_personality_v0 } {
853 %0 = llvm.mlir.constant(1 : i32) : i32
854 %1 = llvm.mlir.constant(2 : i32) : i32
855 %2 = llvm.mlir.constant(3 : i32) : i32
856 // CHECK: llvm.invoke @op_bundle_target() to ^{{.+}} unwind ^{{.+}} : () -> ()
857 llvm.invoke @op_bundle_target() to ^bb2 unwind ^bb1 [] : () -> ()
860 %3 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
867 // CHECK-LABEL: @test_invoke_with_empty_opbundle_operands
868 llvm.func @test_invoke_with_empty_opbundle_operands() attributes { personality = @__gxx_personality_v0 } {
869 %0 = llvm.mlir.constant(1 : i32) : i32
870 %1 = llvm.mlir.constant(2 : i32) : i32
871 %2 = llvm.mlir.constant(3 : i32) : i32
872 // CHECK: llvm.invoke @op_bundle_target() to ^{{.+}} unwind ^{{.+}} ["tag"()] : () -> ()
873 llvm.invoke @op_bundle_target() to ^bb2 unwind ^bb1 ["tag"()] : () -> ()
876 %3 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
883 // CHECK-LABEL: @test_invoke_with_opbundle
884 llvm.func @test_invoke_with_opbundle() attributes { personality = @__gxx_personality_v0 } {
885 %0 = llvm.mlir.constant(1 : i32) : i32
886 %1 = llvm.mlir.constant(2 : i32) : i32
887 %2 = llvm.mlir.constant(3 : i32) : i32
888 // CHECK: llvm.invoke @op_bundle_target() to ^{{.+}} unwind ^{{.+}} ["tag1"(%{{.+}}, %{{.+}} : i32, i32), "tag2"(%{{.+}} : i32)] : () -> ()
889 llvm.invoke @op_bundle_target() to ^bb2 unwind ^bb1 ["tag1"(%0, %1 : i32, i32), "tag2"(%2 : i32)] : () -> ()
892 %3 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
899 // CHECK-LABEL: @test_call_intrin_with_opbundle
900 llvm.func @test_call_intrin_with_opbundle(%arg0 : !llvm.ptr) {
901 %0 = llvm.mlir.constant(1 : i1) : i1
902 %1 = llvm.mlir.constant(16 : i32) : i32
903 // CHECK: llvm.call_intrinsic "llvm.assume"(%{{.+}}) ["align"(%{{.+}}, %{{.+}} : !llvm.ptr, i32)] : (i1) -> ()
904 llvm.call_intrinsic "llvm.assume"(%0) ["align"(%arg0, %1 : !llvm.ptr, i32)] : (i1) -> ()
908 // CHECK-LABEL: @test_assume_intr_no_opbundle
909 llvm.func @test_assume_intr_no_opbundle(%arg0 : !llvm.ptr) {
910 %0 = llvm.mlir.constant(1 : i1) : i1
911 // CHECK: llvm.intr.assume %0 : i1
912 llvm.intr.assume %0 : i1
916 // CHECK-LABEL: @test_assume_intr_empty_opbundle
917 llvm.func @test_assume_intr_empty_opbundle(%arg0 : !llvm.ptr) {
918 %0 = llvm.mlir.constant(1 : i1) : i1
919 // CHECK: llvm.intr.assume %0 : i1
920 llvm.intr.assume %0 [] : i1
924 // CHECK-LABEL: @test_assume_intr_with_opbundles
925 llvm.func @test_assume_intr_with_opbundles(%arg0 : !llvm.ptr) {
926 %0 = llvm.mlir.constant(1 : i1) : i1
927 %1 = llvm.mlir.constant(2 : i32) : i32
928 %2 = llvm.mlir.constant(3 : i32) : i32
929 %3 = llvm.mlir.constant(4 : i32) : i32
930 // CHECK: llvm.intr.assume %0 ["tag1"(%1, %2 : i32, i32), "tag2"(%3 : i32)] : i1
931 llvm.intr.assume %0 ["tag1"(%1, %2 : i32, i32), "tag2"(%3 : i32)] : i1