xref: /llvm-project/flang/test/Lower/OpenMP/delayed-privatization-reduction.f90 (revision d0f67773b213383b6e1c9331fb00f2d4c14bfcb2)
1! Test that reductions and delayed privatization work properly togehter. Since
2! both types of clauses add block arguments to the OpenMP region, we make sure
3! that the block arguments are added in the proper order (reductions first and
4! then delayed privatization.
5
6! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
7! RUN:   -o - %s 2>&1 | FileCheck %s
8! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - %s 2>&1 \
9! RUN:   | FileCheck %s
10
11subroutine red_and_delayed_private
12    integer :: red
13    integer :: prv
14
15    red = 0
16    prv = 10
17
18    !$omp parallel reduction(+:red) private(prv)
19    red = red + 1
20    prv = 20
21    !$omp end parallel
22end subroutine
23
24! CHECK-LABEL: omp.private {type = private}
25! CHECK-SAME: @[[PRIVATIZER_SYM:.*]] : !fir.ref<i32> alloc {
26
27! CHECK-LABEL: omp.declare_reduction
28! CHECK-SAME: @[[REDUCTION_SYM:.*]] : i32 init
29
30! CHECK-LABEL: _QPred_and_delayed_private
31! CHECK: omp.parallel
32! CHECK-SAME: private(@[[PRIVATIZER_SYM]] %{{.*}} -> %arg0 : !fir.ref<i32>)
33! CHECK-SAME: reduction(@[[REDUCTION_SYM]] %{{.*}} -> %arg1 : !fir.ref<i32>) {
34