96 lines · plain
1// RUN: mlir-opt --memref-emulate-wide-int="widest-int-supported=32" %s \2// RUN: --split-input-file --verify-diagnostics | FileCheck %s3 4// Expect no conversions, i32 is supported.5// CHECK-LABEL: func @memref_i326// CHECK: [[M:%.+]] = memref.alloc() : memref<4xi32, 1>7// CHECK-NEXT: [[V:%.+]] = memref.load [[M]][{{%.+}}] : memref<4xi32, 1>8// CHECK-NEXT: memref.store {{%.+}}, [[M]][{{%.+}}] : memref<4xi32, 1>9// CHECK-NEXT: return10func.func @memref_i32() {11 %c0 = arith.constant 0 : index12 %c1 = arith.constant 1 : i3213 %m = memref.alloc() : memref<4xi32, 1>14 %v = memref.load %m[%c0] : memref<4xi32, 1>15 memref.store %c1, %m[%c0] : memref<4xi32, 1>16 return17}18 19// -----20 21// Expect no conversions, f64 is not an integer type.22// CHECK-LABEL: func @memref_f3223// CHECK: [[M:%.+]] = memref.alloc() : memref<4xf32, 1>24// CHECK-NEXT: [[V:%.+]] = memref.load [[M]][{{%.+}}] : memref<4xf32, 1>25// CHECK-NEXT: memref.store {{%.+}}, [[M]][{{%.+}}] : memref<4xf32, 1>26// CHECK-NEXT: return27func.func @memref_f32() {28 %c0 = arith.constant 0 : index29 %c1 = arith.constant 1.0 : f3230 %m = memref.alloc() : memref<4xf32, 1>31 %v = memref.load %m[%c0] : memref<4xf32, 1>32 memref.store %c1, %m[%c0] : memref<4xf32, 1>33 return34}35 36// -----37 38// CHECK-LABEL: func @alloc_load_store_i6439// CHECK: [[C1:%.+]] = arith.constant dense<[1, 0]> : vector<2xi32>40// CHECK-NEXT: [[M:%.+]] = memref.alloc() : memref<4xvector<2xi32>, 1>41// CHECK-NEXT: [[V:%.+]] = memref.load [[M]][{{%.+}}] : memref<4xvector<2xi32>, 1>42// CHECK-NEXT: memref.store [[C1]], [[M]][{{%.+}}] : memref<4xvector<2xi32>, 1>43// CHECK-NEXT: return44func.func @alloc_load_store_i64() {45 %c0 = arith.constant 0 : index46 %c1 = arith.constant 1 : i6447 %m = memref.alloc() : memref<4xi64, 1>48 %v = memref.load %m[%c0] : memref<4xi64, 1>49 memref.store %c1, %m[%c0] : memref<4xi64, 1>50 return51}52 53// -----54 55// CHECK-LABEL: func @alloc_load_store_i64_nontemporal56// CHECK: [[C1:%.+]] = arith.constant dense<[1, 0]> : vector<2xi32>57// CHECK-NEXT: [[M:%.+]] = memref.alloc() : memref<4xvector<2xi32>, 1>58// CHECK-NEXT: [[V:%.+]] = memref.load [[M]][{{%.+}}] {nontemporal = true} : memref<4xvector<2xi32>, 1>59// CHECK-NEXT: memref.store [[C1]], [[M]][{{%.+}}] {nontemporal = true} : memref<4xvector<2xi32>, 1>60// CHECK-NEXT: return61func.func @alloc_load_store_i64_nontemporal() {62 %c0 = arith.constant 0 : index63 %c1 = arith.constant 1 : i6464 %m = memref.alloc() : memref<4xi64, 1>65 %v = memref.load %m[%c0] {nontemporal = true} : memref<4xi64, 1>66 memref.store %c1, %m[%c0] {nontemporal = true} : memref<4xi64, 1>67 return68}69 70// -----71 72// Make sure we do not crash on unsupported types.73func.func @alloc_i128() {74 // expected-error@+1 {{failed to legalize operation 'memref.alloc' that was explicitly marked illegal}}75 %m = memref.alloc() : memref<4xi128, 1>76 return77}78 79// -----80 81func.func @load_i128(%m: memref<4xi128, 1>) {82 %c0 = arith.constant 0 : index83 // expected-error@+1 {{failed to legalize operation 'memref.load' that was explicitly marked illegal}}84 %v = memref.load %m[%c0] : memref<4xi128, 1>85 return86}87 88// -----89 90func.func @store_i128(%c1: i128, %m: memref<4xi128, 1>) {91 %c0 = arith.constant 0 : index92 // expected-error@+1 {{failed to legalize operation 'memref.store' that was explicitly marked illegal}}93 memref.store %c1, %m[%c0] : memref<4xi128, 1>94 return95}96