Skip to content

Commit d137381

Browse files
authored
Add side-effect testcases
1 parent ac6ce80 commit d137381

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// RUN: mlir-opt %s --normalize --mlir-use-nameloc-as-prefix 2>&1 | FileCheck %s
2+
3+
module {
4+
// CHECK-LABEL: func.func @foo(
5+
// CHECK-SAME: %arg0: i32) -> i32 {
6+
// CHECK: %vl13600$funcArg0-funcArg0$ = arith.addi %arg0, %arg0 : i32
7+
// CHECK: return %vl13600$funcArg0-funcArg0$ : i32
8+
// CHECK: }
9+
func.func @foo(%x: i32) -> i32 {
10+
%y = arith.addi %x, %x : i32
11+
return %y : i32
12+
}
13+
// CHECK-LABEL: func.func @bar() -> i32 {
14+
// CHECK: %vl10237$20b04$ = arith.constant 0 : i32
15+
// CHECK: %vl15008$eafb0$ = arith.constant 4 : i32
16+
// CHECK: %vl70789$vl10237-vl15008$ = arith.addi %vl10237$20b04$, %vl15008$eafb0$ : i32
17+
// CHECK: %op27844$vl10237-vl70789$ = arith.addi %vl10237$20b04$, %vl70789$vl10237-vl15008$ : i32
18+
// CHECK: %op27844$op27844-vl15008$ = arith.addi %op27844$vl10237-vl70789$, %vl15008$eafb0$ : i32
19+
// CHECK: %vl16656$bf67a$ = memref.alloc() : memref<4xi32>
20+
// CHECK: %vl77401$e527e$ = arith.constant 0 : index
21+
// CHECK: memref.store %op27844$op27844-vl15008$, %vl16656$bf67a$[%vl77401$e527e$] : memref<4xi32>
22+
// CHECK: %op15672$op27844-op27844$ = arith.addi %op27844$op27844-vl15008$, %op27844$vl10237-vl70789$ : i32
23+
// CHECK: %vl70265$62631$ = arith.constant 1 : index
24+
// CHECK: memref.store %op15672$op27844-op27844$, %vl16656$bf67a$[%vl70265$62631$] : memref<4xi32>
25+
// CHECK: %op27844$vl10237-vl70789$_0 = arith.addi %vl10237$20b04$, %vl70789$vl10237-vl15008$ : i32
26+
// CHECK: %op27844$op27844-vl15008$_1 = arith.addi %op27844$vl10237-vl70789$_0, %vl15008$eafb0$ : i32
27+
// CHECK: %op15672$op27844-op27844$_2 = arith.addi %op27844$op27844-vl15008$_1, %op27844$vl10237-vl70789$_0 : i32
28+
// CHECK: %op43149$vl16656-vl77401$ = memref.load %vl16656$bf67a$[%vl77401$e527e$] : memref<4xi32>
29+
// CHECK: %op43149$vl16656-vl70265$ = memref.load %vl16656$bf67a$[%vl70265$62631$] : memref<4xi32>
30+
// CHECK: %op12004$op43149-op43149$ = arith.addi %op43149$vl16656-vl70265$, %op43149$vl16656-vl77401$ : i32
31+
// CHECK: %op52433foo$op15672$ = call @foo(%op15672$op27844-op27844$_2) : (i32) -> i32
32+
// CHECK: %op91727$op12004-op52433$ = arith.addi %op12004$op43149-op43149$, %op52433foo$op15672$ : i32
33+
// CHECK: return %op91727$op12004-op52433$ : i32
34+
// CHECK: }
35+
36+
func.func @bar() -> i32{
37+
%m0 = memref.alloc() : memref<4xi32>
38+
39+
%c0 = arith.constant 4 : i32
40+
%zero = arith.constant 0 : i32
41+
42+
%idx0 = arith.constant 0 : index
43+
%idx1 = arith.constant 1 : index
44+
45+
%t = arith.addi %zero, %c0 : i32
46+
47+
%t2 = arith.addi %t, %zero : i32
48+
%t3 = arith.addi %t2, %c0 : i32
49+
%t4 = arith.addi %t3, %t2 : i32
50+
51+
memref.store %t3, %m0[%idx0] : memref<4xi32>
52+
memref.store %t4, %m0[%idx1] : memref<4xi32>
53+
54+
%a = memref.load %m0[%idx0] : memref<4xi32>
55+
%b = memref.load %m0[%idx1] : memref<4xi32>
56+
57+
%t5 = arith.addi %t, %zero : i32
58+
%t6 = arith.addi %t5, %c0 : i32
59+
%t7 = arith.addi %t6, %t5 : i32
60+
%t8 = call @foo(%t7) : (i32) -> i32
61+
62+
%t9 = arith.addi %a, %b : i32
63+
%t10 = arith.addi %t9, %t8 : i32
64+
return %t10 : i32
65+
}
66+
}

0 commit comments

Comments
 (0)