106 lines · plain
1// RUN: mlir-opt %s -mlir-use-nameloc-as-prefix -split-input-file | FileCheck %s2// RUN: mlir-opt %s -test-loop-unrolling='unroll-factor=2' -mlir-use-nameloc-as-prefix -split-input-file | FileCheck %s --check-prefix=CHECK-PASS-PRESERVE3 4// CHECK-LABEL: test_basic5func.func @test_basic() {6 %0 = memref.alloc() : memref<i32>7 // CHECK: %alice = memref.load8 %1 = memref.load %0[] : memref<i32> loc("alice")9 return10}11 12// -----13 14// CHECK-LABEL: test_repeat_namelocs15func.func @test_repeat_namelocs() {16 %0 = memref.alloc() : memref<i32>17 // CHECK: %alice = memref.load18 %1 = memref.load %0[] : memref<i32> loc("alice")19 // CHECK: %alice_0 = memref.load20 %2 = memref.load %0[] : memref<i32> loc("alice")21 return22}23 24// -----25 26// CHECK-LABEL: test_bb_args27func.func @test_bb_args1(%arg0 : memref<i32> loc("foo")) {28 // CHECK: %alice = memref.load %foo29 %1 = memref.load %arg0[] : memref<i32> loc("alice")30 return31}32 33// -----34 35func.func private @make_two_results() -> (index, index)36 37// CHECK-LABEL: test_multiple_results38func.func @test_multiple_results(%cond: i1) {39 // CHECK: %foo:2 = call @make_two_results40 %0:2 = call @make_two_results() : () -> (index, index) loc("foo")41 // CHECK: %bar:2 = call @make_two_results42 %1, %2 = call @make_two_results() : () -> (index, index) loc("bar")43 44 // CHECK: %kevin:2 = scf.while (%arg1 = %bar#0, %arg2 = %bar#0)45 %5:2 = scf.while (%arg1 = %1, %arg2 = %1) : (index, index) -> (index, index) {46 %6 = arith.cmpi slt, %arg1, %arg2 : index47 scf.condition(%6) %arg1, %arg2 : index, index48 } do {49 // CHECK: ^bb0(%alice: index, %bob: index)50 ^bb0(%arg3 : index loc("alice"), %arg4: index loc("bob")):51 %c1, %c2 = func.call @make_two_results() : () -> (index, index) loc("harriet")52 // CHECK: scf.yield %harriet#1, %harriet#153 scf.yield %c2, %c2 : index, index54 } loc("kevin")55 return56}57 58// -----59 60#map = affine_map<(d0) -> (d0)>61#trait = {62 iterator_types = ["parallel"],63 indexing_maps = [#map, #map, #map]64}65 66// CHECK-LABEL: test_op_asm_interface67func.func @test_op_asm_interface(%arg0: tensor<?xf32>, %arg1: tensor<?xf32>) {68 // CHECK: %c0 = arith.constant69 %0 = arith.constant 0 : index70 // CHECK: %foo = arith.constant71 %1 = arith.constant 1 : index loc("foo")72 73 linalg.generic #trait ins(%arg0: tensor<?xf32>) outs(%arg0, %arg1: tensor<?xf32>, tensor<?xf32>) {74 // CHECK: ^bb0(%in: f32, %out: f32, %out_0: f32)75 ^bb0(%a: f32, %b: f32, %c: f32):76 linalg.yield %a, %a : f32, f3277 } -> (tensor<?xf32>, tensor<?xf32>)78 79 linalg.generic #trait ins(%arg0: tensor<?xf32>) outs(%arg0, %arg1: tensor<?xf32>, tensor<?xf32>) {80 // CHECK: ^bb0(%bar: f32, %alice: f32, %steve: f32)81 ^bb0(%a: f32 loc("bar"), %b: f32 loc("alice"), %c: f32 loc("steve")):82 // CHECK: linalg.yield %alice, %steve83 linalg.yield %b, %c : f32, f3284 } -> (tensor<?xf32>, tensor<?xf32>)85 86 return87}88 89// -----90 91// CHECK-LABEL: test_pass92func.func @test_pass(%arg0: memref<4xf32>, %arg1: memref<4xf32>) {93 %c0 = arith.constant 0 : index94 %c1 = arith.constant 1 : index95 %c4 = arith.constant 4 : index96 scf.for %arg2 = %c0 to %c4 step %c1 {97 // CHECK-PASS-PRESERVE: %foo = memref.load98 // CHECK-PASS-PRESERVE: memref.store %foo99 // CHECK-PASS-PRESERVE: %foo_1 = memref.load100 // CHECK-PASS-PRESERVE: memref.store %foo_1101 %0 = memref.load %arg0[%arg2] : memref<4xf32> loc("foo")102 memref.store %0, %arg1[%arg2] : memref<4xf32>103 }104 return105}106