1 !RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes="FIRDialect,OMPDialect"
2 !RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --cfg-conversion | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefixes="OMPDialect"
4 !===============================================================================
5 ! parallel construct with function call which has master construct internally
6 !===============================================================================
7 !FIRDialect-LABEL: func @_QPomp_master
8 subroutine omp_master()
10 !OMPDialect: omp.master {
13 !FIRDialect: fir.call @_QPmaster() {{.*}}: () -> ()
16 !OMPDialect: omp.terminator
19 end subroutine omp_master
21 !FIRDialect-LABEL: func @_QPparallel_function_master
22 subroutine parallel_function_master()
24 !OMPDialect: omp.parallel {
27 !FIRDialect: fir.call @_QPfoo() {{.*}}: () -> ()
30 !OMPDialect: omp.terminator
33 end subroutine parallel_function_master
35 !===============================================================================
36 ! master construct nested inside parallel construct
37 !===============================================================================
39 !FIRDialect-LABEL: func @_QPomp_parallel_master
40 subroutine omp_parallel_master()
42 !OMPDialect: omp.parallel {
44 !FIRDialect: fir.call @_QPparallel() {{.*}}: () -> ()
47 !OMPDialect: omp.master {
50 !FIRDialect: fir.call @_QPparallel_master() {{.*}}: () -> ()
51 call parallel_master()
53 !OMPDialect: omp.terminator
56 !OMPDialect: omp.terminator
59 end subroutine omp_parallel_master
61 !===============================================================================
62 ! master construct nested inside parallel construct with conditional flow
63 !===============================================================================
65 !FIRDialect-LABEL: func @_QPomp_master_parallel
66 subroutine omp_master_parallel()
67 integer :: alpha
, beta
, gama
72 !OMPDialect: omp.master {
75 !FIRDialect: %{{.*}} = fir.load %{{.*}}
76 !FIRDialect: %{{.*}} = fir.load %{{.*}}
77 !FIRDialect: %[[RESULT:.*]] = arith.cmpi sge, %{{.*}}, %{{.*}}
78 !FIRDialect: fir.if %[[RESULT]] {
79 if (alpha
.ge
. gama
) then
81 !OMPDialect: omp.parallel {
83 !FIRDialect: fir.call @_QPinside_if_parallel() {{.*}}: () -> ()
84 call inside_if_parallel()
86 !OMPDialect: omp.terminator
89 !FIRDialect: %{{.*}} = fir.load %{{.*}}
90 !FIRDialect: %{{.*}} = fir.load %{{.*}}
91 !FIRDialect: %{{.*}} = arith.addi %{{.*}}, %{{.*}}
92 !FIRDialect: fir.store %{{.*}} to %{{.*}}
97 !OMPDialect: omp.terminator
100 end subroutine omp_master_parallel