1 // RUN: mlir-opt %s --pass-pipeline='builtin.module(any(mem2reg))' --split-input-file | FileCheck %s
3 // Verifies that allocators with mutliple slots are handled properly.
5 // CHECK-LABEL: func.func @multi_slot_alloca
6 func.func @multi_slot_alloca() -> (i32, i32) {
7 // CHECK-NOT: test.multi_slot_alloca
8 %1, %2 = test.multi_slot_alloca : () -> (memref<i32>, memref<i32>)
9 %3 = memref.load %1[] : memref<i32>
10 %4 = memref.load %2[] : memref<i32>
11 return %3, %4 : i32, i32
16 // Verifies that a multi slot allocator can be partially promoted.
18 func.func private @consumer(memref<i32>)
20 // CHECK-LABEL: func.func @multi_slot_alloca_only_second
21 func.func @multi_slot_alloca_only_second() -> (i32, i32) {
22 // CHECK: %{{[[:alnum:]]+}} = test.multi_slot_alloca
23 %1, %2 = test.multi_slot_alloca : () -> (memref<i32>, memref<i32>)
24 func.call @consumer(%1) : (memref<i32>) -> ()
25 %3 = memref.load %1[] : memref<i32>
26 %4 = memref.load %2[] : memref<i32>
27 return %3, %4 : i32, i32
32 // Checks that slots are not promoted if used in a graph region.
34 // CHECK-LABEL: test.isolated_graph_region
35 test.isolated_graph_region {
36 // CHECK: %{{[[:alnum:]]+}} = test.multi_slot_alloca
37 %slot = test.multi_slot_alloca : () -> (memref<i32>)
38 memref.store %a, %slot[] : memref<i32>
39 %a = memref.load %slot[] : memref<i32>
40 "test.foo"() : () -> ()