brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 4b27f33 Raw
42 lines · plain
1// RUN: mlir-opt %s --pass-pipeline='builtin.module(any(mem2reg))' --split-input-file | FileCheck %s2 3// Verifies that allocators with multiple slots are handled properly.4 5// CHECK-LABEL: func.func @multi_slot_alloca6func.func @multi_slot_alloca() -> (i32, i32) {7  // CHECK-NOT: test.multi_slot_alloca8  %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, i3212}13 14// -----15 16// Verifies that a multi slot allocator can be partially promoted.17 18func.func private @consumer(memref<i32>)19 20// CHECK-LABEL: func.func @multi_slot_alloca_only_second21func.func @multi_slot_alloca_only_second() -> (i32, i32) {22  // CHECK: %{{[[:alnum:]]+}} = test.multi_slot_alloca23  %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, i3228}29 30// -----31 32// Checks that slots are not promoted if used in a graph region.33 34// CHECK-LABEL: test.isolated_graph_region35test.isolated_graph_region {36  // CHECK: %{{[[:alnum:]]+}} = test.multi_slot_alloca37  %slot = test.multi_slot_alloca : () -> (memref<i32>)38  memref.store %a, %slot[] : memref<i32>39  %a = memref.load %slot[] : memref<i32>40  "test.foo"() : () -> ()41}42