1 // RUN: mlir-opt %s --pass-pipeline='builtin.module(func.func(sroa))' --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 %0 = arith.constant 0 : index
8 %1, %2 = test.multi_slot_alloca : () -> (memref<2xi32>, memref<4xi32>)
9 // CHECK-COUNT-2: test.multi_slot_alloca : () -> memref<i32>
10 %3 = memref.load %1[%0] {first}: memref<2xi32>
11 %4 = memref.load %2[%0] {second} : memref<4xi32>
12 return %3, %4 : i32, i32
17 // Verifies that a multi slot allocator can be partially destructured.
19 func.func private @consumer(memref<2xi32>)
21 // CHECK-LABEL: func.func @multi_slot_alloca_only_second
22 func.func @multi_slot_alloca_only_second() -> (i32, i32) {
23 %0 = arith.constant 0 : index
24 // CHECK: test.multi_slot_alloca : () -> memref<2xi32>
25 // CHECK: test.multi_slot_alloca : () -> memref<i32>
26 %1, %2 = test.multi_slot_alloca : () -> (memref<2xi32>, memref<4xi32>)
27 func.call @consumer(%1) : (memref<2xi32>) -> ()
28 %3 = memref.load %1[%0] : memref<2xi32>
29 %4 = memref.load %2[%0] : memref<4xi32>
30 return %3, %4 : i32, i32