aboutsummaryrefslogtreecommitdiff
path: root/mlir/test/Dialect/MemRef/emulate-wide-int.mlir
blob: 65ac5beed0a1ded461b411a747669f9925cbd6b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// RUN: mlir-opt --memref-emulate-wide-int="widest-int-supported=32" %s | FileCheck %s

// Expect no conversions, i32 is supported.
// CHECK-LABEL: func @memref_i32
// CHECK:         [[M:%.+]] = memref.alloc() : memref<4xi32, 1>
// CHECK-NEXT:    [[V:%.+]] = memref.load [[M]][{{%.+}}] : memref<4xi32, 1>
// CHECK-NEXT:    memref.store {{%.+}}, [[M]][{{%.+}}] : memref<4xi32, 1>
// CHECK-NEXT:    return
func.func @memref_i32() {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : i32
    %m = memref.alloc() : memref<4xi32, 1>
    %v = memref.load %m[%c0] : memref<4xi32, 1>
    memref.store %c1, %m[%c0] : memref<4xi32, 1>
    return
}

// Expect no conversions, f64 is not an integer type.
// CHECK-LABEL: func @memref_f32
// CHECK:         [[M:%.+]] = memref.alloc() : memref<4xf32, 1>
// CHECK-NEXT:    [[V:%.+]] = memref.load [[M]][{{%.+}}] : memref<4xf32, 1>
// CHECK-NEXT:    memref.store {{%.+}}, [[M]][{{%.+}}] : memref<4xf32, 1>
// CHECK-NEXT:    return
func.func @memref_f32() {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1.0 : f32
    %m = memref.alloc() : memref<4xf32, 1>
    %v = memref.load %m[%c0] : memref<4xf32, 1>
    memref.store %c1, %m[%c0] : memref<4xf32, 1>
    return
}

// CHECK-LABEL: func @alloc_load_store_i64
// CHECK:         [[C1:%.+]] = arith.constant dense<[1, 0]> : vector<2xi32>
// CHECK-NEXT:    [[M:%.+]]  = memref.alloc() : memref<4xvector<2xi32>, 1>
// CHECK-NEXT:    [[V:%.+]]  = memref.load [[M]][{{%.+}}] : memref<4xvector<2xi32>, 1>
// CHECK-NEXT:    memref.store [[C1]], [[M]][{{%.+}}] : memref<4xvector<2xi32>, 1>
// CHECK-NEXT:    return
func.func @alloc_load_store_i64() {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : i64
    %m = memref.alloc() : memref<4xi64, 1>
    %v = memref.load %m[%c0] : memref<4xi64, 1>
    memref.store %c1, %m[%c0] : memref<4xi64, 1>
    return
}


// CHECK-LABEL: func @alloc_load_store_i64_nontemporal
// CHECK:         [[C1:%.+]] = arith.constant dense<[1, 0]> : vector<2xi32>
// CHECK-NEXT:    [[M:%.+]]  = memref.alloc() : memref<4xvector<2xi32>, 1>
// CHECK-NEXT:    [[V:%.+]]  = memref.load [[M]][{{%.+}}] {nontemporal = true} : memref<4xvector<2xi32>, 1>
// CHECK-NEXT:    memref.store [[C1]], [[M]][{{%.+}}] {nontemporal = true} : memref<4xvector<2xi32>, 1>
// CHECK-NEXT:    return
func.func @alloc_load_store_i64_nontemporal() {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : i64
    %m = memref.alloc() : memref<4xi64, 1>
    %v = memref.load %m[%c0] {nontemporal = true} : memref<4xi64, 1>
    memref.store %c1, %m[%c0] {nontemporal = true} : memref<4xi64, 1>
    return
}