1! This test checks lowering of OpenMP ordered directive with threads Clause.
2! Without clause in ordered direcitve, it behaves as if threads clause is
3! specified.
4
5!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefix=FIRDialect
6!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIRDialect
7!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | tco | FileCheck %s --check-prefix=LLVMIR
8
9subroutine ordered
10        integer :: i
11        integer :: a(20)
12
13!FIRDialect: omp.ordered_region  {
14!LLVMIRDialect: omp.ordered_region  {
15!LLVMIR: [[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB0:[0-9]+]]), !dbg !{{.*}}
16!LLVMIR-NEXT: call void @__kmpc_ordered(ptr @[[GLOB0]], i32 [[TMP0]]), !dbg !{{.*}}
17!$OMP ORDERED
18        a(i) = a(i-1) + 1
19!FIRDialect:   omp.terminator
20!FIRDialect-NEXT: }
21!LLVMIRDialect:   omp.terminator
22!LLVMIRDialect-NEXT: }
23!LLVMIR: call void @__kmpc_end_ordered(ptr @[[GLOB0]], i32 [[TMP0]]), !dbg !{{.*}}
24!$OMP END ORDERED
25
26!FIRDialect: omp.ordered_region  {
27!LLVMIRDialect: omp.ordered_region  {
28!LLVMIR: [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]]), !dbg !{{.*}}
29!LLVMIR-NEXT: call void @__kmpc_ordered(ptr @[[GLOB1]], i32 [[TMP1]]), !dbg !{{.*}}
30!$OMP ORDERED THREADS
31        a(i) = a(i-1) + 1
32!FIRDialect:   omp.terminator
33!FIRDialect-NEXT: }
34!LLVMIRDialect:   omp.terminator
35!LLVMIRDialect-NEXT: }
36!LLVMIR: call void @__kmpc_end_ordered(ptr @[[GLOB1]], i32 [[TMP1]]), !dbg !{{.*}}
37!LLVMIR-NEXT: ret void, !dbg !{{.*}}
38!$OMP END ORDERED
39
40end
41