|
| 1 | +// RUN: fir-opt --lower-workshare --allow-unregistered-dialect %s | FileCheck %s |
| 2 | + |
| 3 | +// Checks that fir.alloca is hoisted out and copyprivate'd |
| 4 | +func.func @wsfunc() { |
| 5 | + omp.workshare { |
| 6 | + %c1 = arith.constant 1 : index |
| 7 | + %c42 = arith.constant 42 : index |
| 8 | + %c1_i32 = arith.constant 1 : i32 |
| 9 | + %alloc = fir.alloca i32 |
| 10 | + fir.store %c1_i32 to %alloc : !fir.ref<i32> |
| 11 | + omp.workshare.loop_wrapper { |
| 12 | + omp.loop_nest (%arg1) : index = (%c1) to (%c42) inclusive step (%c1) { |
| 13 | + "test.test1"(%alloc) : (!fir.ref<i32>) -> () |
| 14 | + omp.yield |
| 15 | + } |
| 16 | + omp.terminator |
| 17 | + } |
| 18 | + "test.test2"(%alloc) : (!fir.ref<i32>) -> () |
| 19 | + omp.terminator |
| 20 | + } |
| 21 | + return |
| 22 | +} |
| 23 | + |
| 24 | +// CHECK-LABEL: func.func private @_workshare_copy_i32( |
| 25 | +// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>, |
| 26 | +// CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>) { |
| 27 | +// CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32> |
| 28 | +// CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<i32> |
| 29 | +// CHECK: return |
| 30 | +// CHECK: } |
| 31 | + |
| 32 | +// CHECK-LABEL: func.func @wsfunc() { |
| 33 | +// CHECK: %[[VAL_0:.*]] = fir.alloca i32 |
| 34 | +// CHECK: omp.single copyprivate(%[[VAL_0]] -> @_workshare_copy_i32 : !fir.ref<i32>) { |
| 35 | +// CHECK: %[[VAL_1:.*]] = arith.constant 1 : i32 |
| 36 | +// CHECK: fir.store %[[VAL_1]] to %[[VAL_0]] : !fir.ref<i32> |
| 37 | +// CHECK: omp.terminator |
| 38 | +// CHECK: } |
| 39 | +// CHECK: %[[VAL_2:.*]] = arith.constant 1 : index |
| 40 | +// CHECK: %[[VAL_3:.*]] = arith.constant 42 : index |
| 41 | +// CHECK: omp.wsloop { |
| 42 | +// CHECK: omp.loop_nest (%[[VAL_4:.*]]) : index = (%[[VAL_2]]) to (%[[VAL_3]]) inclusive step (%[[VAL_2]]) { |
| 43 | +// CHECK: "test.test1"(%[[VAL_0]]) : (!fir.ref<i32>) -> () |
| 44 | +// CHECK: omp.yield |
| 45 | +// CHECK: } |
| 46 | +// CHECK: omp.terminator |
| 47 | +// CHECK: } |
| 48 | +// CHECK: omp.single nowait { |
| 49 | +// CHECK: "test.test2"(%[[VAL_0]]) : (!fir.ref<i32>) -> () |
| 50 | +// CHECK: omp.terminator |
| 51 | +// CHECK: } |
| 52 | +// CHECK: omp.barrier |
| 53 | +// CHECK: return |
| 54 | +// CHECK: } |
| 55 | + |
0 commit comments