55 lines · plain
1// RUN: fir-opt --lower-workshare --allow-unregistered-dialect %s | FileCheck %s2 3// Checks that fir.alloca is hoisted out and copyprivate'd4func.func @wsfunc() {5 omp.workshare {6 %c1 = arith.constant 1 : index7 %c42 = arith.constant 42 : index8 %c1_i32 = arith.constant 1 : i329 %alloc = fir.alloca i3210 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.yield15 }16 }17 "test.test2"(%alloc) : (!fir.ref<i32>) -> ()18 omp.terminator19 }20 return21}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: return30// CHECK: }31 32// CHECK-LABEL: func.func @wsfunc() {33// CHECK: %[[VAL_0:.*]] = fir.alloca i3234// CHECK: omp.single copyprivate(%[[VAL_0]] -> @_workshare_copy_i32 : !fir.ref<i32>) {35// CHECK: %[[VAL_1:.*]] = arith.constant 1 : i3236// CHECK: fir.store %[[VAL_1]] to %[[VAL_0]] : !fir.ref<i32>37// CHECK: omp.terminator38// CHECK: }39// CHECK: %[[VAL_2:.*]] = arith.constant 1 : index40// CHECK: %[[VAL_3:.*]] = arith.constant 42 : index41// 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.yield45// CHECK: }46// CHECK: }47// CHECK: omp.single nowait {48// CHECK: "test.test2"(%[[VAL_0]]) : (!fir.ref<i32>) -> ()49// CHECK: omp.terminator50// CHECK: }51// CHECK: omp.barrier52// CHECK: return53// CHECK: }54 55