Skip to content

Commit fd782e9

Browse files
committed
Test the tmp storing logic
1 parent 8b4363f commit fd782e9

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

flang/test/Transforms/OpenMP/lower-workshare.mlir

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func.func @wsfunc(%arg0: !fir.ref<!fir.array<42xi32>>) {
3636
return
3737
}
3838

39-
4039
// -----
4140

4241
// checks:
@@ -190,4 +189,3 @@ func.func @wsfunc(%arg0: !fir.ref<!fir.array<42xi32>>) {
190189
// CHECK: }
191190
// CHECK: return
192191
// CHECK: }
193-
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// RUN: fir-opt --split-input-file --lower-workshare --allow-unregistered-dialect %s | FileCheck %s
2+
3+
4+
// tests if the correct values are stored
5+
6+
func.func @wsfunc(%arg0: !fir.ref<!fir.array<42xi32>>) {
7+
omp.parallel {
8+
// CHECK: fir.alloca
9+
// CHECK: fir.alloca
10+
// CHECK: fir.alloca
11+
// CHECK: fir.alloca
12+
// CHECK: fir.alloca
13+
// CHECK-NOT: fir.alloca
14+
omp.workshare {
15+
16+
%t1 = "test.test1"() : () -> i32
17+
// CHECK: %[[T1:.*]] = "test.test1"
18+
// CHECK: fir.store %[[T1]]
19+
%t2 = "test.test2"() : () -> i32
20+
// CHECK: %[[T2:.*]] = "test.test2"
21+
// CHECK: fir.store %[[T2]]
22+
%t3 = "test.test3"() : () -> i32
23+
// CHECK: %[[T3:.*]] = "test.test3"
24+
// CHECK-NOT: fir.store %[[T3]]
25+
%t4 = "test.test4"() : () -> i32
26+
// CHECK: %[[T4:.*]] = "test.test4"
27+
// CHECK: fir.store %[[T4]]
28+
%t5 = "test.test5"() : () -> i32
29+
// CHECK: %[[T5:.*]] = "test.test5"
30+
// CHECK: fir.store %[[T5]]
31+
%t6 = "test.test6"() : () -> i32
32+
// CHECK: %[[T6:.*]] = "test.test6"
33+
// CHECK-NOT: fir.store %[[T6]]
34+
35+
36+
"test.test1"(%t1) : (i32) -> ()
37+
"test.test1"(%t2) : (i32) -> ()
38+
"test.test1"(%t3) : (i32) -> ()
39+
40+
%true = arith.constant true
41+
fir.if %true {
42+
"test.test2"(%t3) : (i32) -> ()
43+
}
44+
45+
%c1_i32 = arith.constant 1 : i32
46+
47+
%t5_pure_use = arith.addi %t5, %c1_i32 : i32
48+
49+
%t6_mem_effect_use = "test.test8"(%t6) : (i32) -> i32
50+
// CHECK: %[[T6_USE:.*]] = "test.test8"
51+
// CHECK: fir.store %[[T6_USE]]
52+
53+
%c42 = arith.constant 42 : index
54+
%c1 = arith.constant 1 : index
55+
"omp.workshare_loop_wrapper"() ({
56+
omp.loop_nest (%arg1) : index = (%c1) to (%c42) inclusive step (%c1) {
57+
"test.test10"(%t1) : (i32) -> ()
58+
"test.test10"(%t5_pure_use) : (i32) -> ()
59+
"test.test10"(%t6_mem_effect_use) : (i32) -> ()
60+
omp.yield
61+
}
62+
omp.terminator
63+
}) : () -> ()
64+
65+
"test.test10"(%t2) : (i32) -> ()
66+
fir.if %true {
67+
"test.test10"(%t4) : (i32) -> ()
68+
}
69+
omp.terminator
70+
}
71+
omp.terminator
72+
}
73+
return
74+
}

0 commit comments

Comments
 (0)