| 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 |
} |
| 17 |
"test.test2"(%alloc) : (!fir.ref<i32>) -> () |
| 18 |
omp.terminator |
| 19 |
} |
| 20 |
return |
| 21 |
} |
| 22 |
|
| 23 |
// CHECK-LABEL: func.func private @_workshare_copy_i32( |
| 24 |
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>, |
| 25 |
// CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>) |
| 26 |
// CHECK-SAME: attributes {llvm.linkage = #llvm.linkage<internal>} { |
| 27 |
// CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32> |
| 28 |
// CHECK: fir.store %[[VAL_2]] to %[[VAL_0]] : !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: } |
| 47 |
// CHECK: omp.single nowait { |
| 48 |
// CHECK: "test.test2"(%[[VAL_0]]) : (!fir.ref<i32>) -> () |
| 49 |
// CHECK: omp.terminator |
| 50 |
// CHECK: } |
| 51 |
// CHECK: omp.barrier |
| 52 |
// CHECK: return |
| 53 |
// CHECK: } |
| 54 |
|