Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenMP / master.f90
blob3a607eea0fb5024cd0d6f32f32b214dcef0d5d5a
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 {
11 !$omp master
13 !FIRDialect: fir.call @_QPmaster() {{.*}}: () -> ()
14 call master()
16 !OMPDialect: omp.terminator
17 !$omp end master
19 end subroutine omp_master
21 !FIRDialect-LABEL: func @_QPparallel_function_master
22 subroutine parallel_function_master()
24 !OMPDialect: omp.parallel {
25 !$omp parallel
27 !FIRDialect: fir.call @_QPfoo() {{.*}}: () -> ()
28 call foo()
30 !OMPDialect: omp.terminator
31 !$omp end parallel
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 {
43 !$omp parallel
44 !FIRDialect: fir.call @_QPparallel() {{.*}}: () -> ()
45 call parallel()
47 !OMPDialect: omp.master {
48 !$omp master
50 !FIRDialect: fir.call @_QPparallel_master() {{.*}}: () -> ()
51 call parallel_master()
53 !OMPDialect: omp.terminator
54 !$omp end master
56 !OMPDialect: omp.terminator
57 !$omp end parallel
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
68 alpha = 4
69 beta = 5
70 gama = 6
72 !OMPDialect: omp.master {
73 !$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 {
82 !$omp parallel
83 !FIRDialect: fir.call @_QPinside_if_parallel() {{.*}}: () -> ()
84 call inside_if_parallel()
86 !OMPDialect: omp.terminator
87 !$omp end parallel
89 !FIRDialect: %{{.*}} = fir.load %{{.*}}
90 !FIRDialect: %{{.*}} = fir.load %{{.*}}
91 !FIRDialect: %{{.*}} = arith.addi %{{.*}}, %{{.*}}
92 !FIRDialect: fir.store %{{.*}} to %{{.*}}
93 beta = alpha + gama
94 end if
95 !FIRDialect: else
97 !OMPDialect: omp.terminator
98 !$omp end master
100 end subroutine omp_master_parallel