// RUN: npcomp-opt -lower-structural-to-memref <%s | FileCheck %s --dump-input=fail // Basic cases. // CHECK-LABEL: func @identity(%arg0: memref) -> memref { // CHECK-NEXT: return %arg0 : memref func @identity(%arg0: tensor) -> tensor { return %arg0 : tensor } // CHECK-LABEL: func @bb_arg(%arg0: memref) -> memref { // CHECK-NEXT: br ^bb1(%arg0 : memref) // CHECK-NEXT: ^bb1(%[[BBARG:.*]]: memref): // CHECK-NEXT: return %[[BBARG]] : memref func @bb_arg(%arg0: tensor) -> tensor { br ^bb1(%arg0: tensor) ^bb1(%bbarg: tensor): return %bbarg : tensor } // CHECK-LABEL: func @select(%arg0: i1, %arg1: memref, %arg2: memref) -> memref { // CHECK-NEXT: %[[RET:.*]] = select %arg0, %arg1, %arg2 : memref // CHECK-NEXT: return %[[RET]] : memref func @select(%pred: i1, %true_val: tensor, %false_val: tensor) -> tensor { %0 = std.select %pred, %true_val, %false_val : tensor return %0 : tensor } // Test the interactions with materializations. // Note: this pass never actually expects IR with memref argument types. // We use memref-typed arguments purely for testing convenience. // CHECK-LABEL: func @identity_materializations(%arg0: memref) -> memref { // CHECK-NEXT: return %arg0 : memref func @identity_materializations(%arg0: tensor) -> tensor { %0 = tensor_to_memref %arg0 : memref %1 = tensor_load %0 : memref return %1 : tensor } // CHECK-LABEL: func @elide_tensor_load(%arg0: memref) -> memref { // CHECK-NEXT: return %arg0 : memref func @elide_tensor_load(%arg0: memref) -> tensor { %0 = tensor_load %arg0 : memref return %0 : tensor } // CHECK-LABEL: func @elide_tensor_to_memref(%arg0: memref) -> memref { // CHECK-NEXT: return %arg0 : memref func @elide_tensor_to_memref(%arg0: tensor) -> memref { %0 = tensor_to_memref %arg0 : memref return %0 : memref }