xref: /llvm-project/flang/test/Lower/OpenMP/wsloop-ordered.f90 (revision 937cbce14c9aa956342a9c818c26a8a557802843)
15b66987cSKiran Chandramohan! This test checks lowering of worksharing-loop construct with ordered clause.
25b66987cSKiran Chandramohan
35b66987cSKiran Chandramohan! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
45b66987cSKiran Chandramohan
55b66987cSKiran Chandramohan! This checks lowering ordered clause specified without parameter
65b66987cSKiran Chandramohansubroutine wsloop_ordered_no_para()
75b66987cSKiran Chandramohan  integer :: a(10), i
85b66987cSKiran Chandramohan
9*937cbce1SKareem Ergawy! CHECK:  omp.wsloop ordered(0) {
10ca4dbc27SSergio Afonso! CHECK-NEXT: omp.loop_nest (%{{.*}}) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) {
115b66987cSKiran Chandramohan! CHECK:        omp.yield
125b66987cSKiran Chandramohan! CHECK:      }
13ca4dbc27SSergio Afonso! CHECK:    }
145b66987cSKiran Chandramohan
155b66987cSKiran Chandramohan  !$omp do ordered
165b66987cSKiran Chandramohan  do i = 2, 10
175b66987cSKiran Chandramohan    !$omp ordered
185b66987cSKiran Chandramohan    a(i) = a(i-1) + 1
195b66987cSKiran Chandramohan    !$omp end ordered
205b66987cSKiran Chandramohan  end do
215b66987cSKiran Chandramohan  !$omp end do
225b66987cSKiran Chandramohan
235b66987cSKiran Chandramohanend
245b66987cSKiran Chandramohan
255b66987cSKiran Chandramohan! This checks lowering ordered clause specified with a parameter
265b66987cSKiran Chandramohansubroutine wsloop_ordered_with_para()
275b66987cSKiran Chandramohan  integer :: a(10), i
285b66987cSKiran Chandramohan
295b66987cSKiran Chandramohan! CHECK: func @_QPwsloop_ordered_with_para() {
30*937cbce1SKareem Ergawy! CHECK:  omp.wsloop ordered(1) {
31ca4dbc27SSergio Afonso! CHECK-NEXT: omp.loop_nest (%{{.*}}) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) {
325b66987cSKiran Chandramohan! CHECK:        omp.yield
335b66987cSKiran Chandramohan! CHECK:      }
34ca4dbc27SSergio Afonso! CHECK:    }
355b66987cSKiran Chandramohan
365b66987cSKiran Chandramohan  !$omp do ordered(1)
375b66987cSKiran Chandramohan  do i = 2, 10
385b66987cSKiran Chandramohan    !!$omp ordered depend(sink: i-1)
395b66987cSKiran Chandramohan    a(i) = a(i-1) + 1
405b66987cSKiran Chandramohan    !!$omp ordered depend(source)
415b66987cSKiran Chandramohan  end do
425b66987cSKiran Chandramohan  !$omp end do
435b66987cSKiran Chandramohan
445b66987cSKiran Chandramohanend
45