1// RUN: mlir-opt %s -arith-bufferize | FileCheck %s
2
3// CHECK-LABEL:   func @index_cast(
4// CHECK-SAME:  %[[TENSOR:.*]]: tensor<i32>, %[[SCALAR:.*]]: i32
5func @index_cast(%tensor: tensor<i32>, %scalar: i32) -> (tensor<index>, index) {
6  %index_tensor = arith.index_cast %tensor : tensor<i32> to tensor<index>
7  %index_scalar = arith.index_cast %scalar : i32 to index
8  return %index_tensor, %index_scalar : tensor<index>, index
9}
10// CHECK:  %[[MEMREF:.*]] = bufferization.to_memref %[[TENSOR]] : memref<i32>
11// CHECK-NEXT: %[[INDEX_MEMREF:.*]] = arith.index_cast %[[MEMREF]]
12// CHECK-SAME:   memref<i32> to memref<index>
13// CHECK-NEXT: %[[INDEX_TENSOR:.*]] = bufferization.to_tensor %[[INDEX_MEMREF]]
14// CHECK: return %[[INDEX_TENSOR]]
15