[flang-commits] [flang] 903faef - [Flang][OpenMP] Port three tests to HLFIR flow
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Mon Oct 16 08:18:01 PDT 2023
Author: Kiran Chandramohan
Date: 2023-10-16T15:16:03Z
New Revision: 903faefc14eb838a20c0526a14d44dbb0fcea85b
URL: https://github.com/llvm/llvm-project/commit/903faefc14eb838a20c0526a14d44dbb0fcea85b
DIFF: https://github.com/llvm/llvm-project/commit/903faefc14eb838a20c0526a14d44dbb0fcea85b.diff
LOG: [Flang][OpenMP] Port three tests to HLFIR flow
These are copies of tests from flang/test/Lower/OpenMP/FIR
Added:
flang/test/Lower/OpenMP/firstprivate-commonblock.f90
flang/test/Lower/OpenMP/unstructured.f90
flang/test/Lower/OpenMP/wsloop.f90
Modified:
Removed:
################################################################################
diff --git a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
new file mode 100644
index 000000000000000..ff064a74d491a86
--- /dev/null
+++ b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
@@ -0,0 +1,34 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+
+!CHECK: func.func @_QPfirstprivate_common() {
+!CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<8xi8>>
+!CHECK: %[[val_1:.*]] = fir.convert %[[val_0]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
+!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
+!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
+!CHECK: %[[val_3:.*]] = fir.convert %[[val_2]] : (!fir.ref<i8>) -> !fir.ref<f32>
+!CHECK: %[[VAL_3_DECL:.*]]:2 = hlfir.declare %[[val_3]] {uniq_name = "_QFfirstprivate_commonEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: %[[val_4:.*]] = fir.convert %[[val_0]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
+!CHECK: %[[val_c4:.*]] = arith.constant 4 : index
+!CHECK: %[[val_5:.*]] = fir.coordinate_of %[[val_4]], %[[val_c4]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
+!CHECK: %[[val_6:.*]] = fir.convert %[[val_5]] : (!fir.ref<i8>) -> !fir.ref<f32>
+!CHECK: %[[VAL_6_DECL:.*]]:2 = hlfir.declare %[[val_6]] {uniq_name = "_QFfirstprivate_commonEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: omp.parallel {
+!CHECK: %[[val_7:.*]] = fir.alloca f32 {bindc_name = "x", pinned, uniq_name = "_QFfirstprivate_commonEx"}
+!CHECK: %[[VAL_7_DECL:.*]]:2 = hlfir.declare %[[val_7]] {uniq_name = "_QFfirstprivate_commonEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: %[[val_8:.*]] = fir.load %[[VAL_3_DECL]]#1 : !fir.ref<f32>
+!CHECK: fir.store %[[val_8]] to %[[VAL_7_DECL]]#1 : !fir.ref<f32>
+!CHECK: %[[val_9:.*]] = fir.alloca f32 {bindc_name = "y", pinned, uniq_name = "_QFfirstprivate_commonEy"}
+!CHECK: %[[VAL_9_DECL:.*]]:2 = hlfir.declare %[[val_9]] {uniq_name = "_QFfirstprivate_commonEy"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+!CHECK: %[[val_10:.*]] = fir.load %[[VAL_6_DECL]]#1 : !fir.ref<f32>
+!CHECK: fir.store %[[val_10]] to %[[VAL_9_DECL]]#1 : !fir.ref<f32>
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: return
+!CHECK: }
+
+subroutine firstprivate_common
+ common /c/ x, y
+ real x, y
+ !$omp parallel firstprivate(/c/)
+ !$omp end parallel
+end subroutine
diff --git a/flang/test/Lower/OpenMP/unstructured.f90 b/flang/test/Lower/OpenMP/unstructured.f90
new file mode 100644
index 000000000000000..e5bf980ce90fd0b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/unstructured.f90
@@ -0,0 +1,348 @@
+! Test unstructured code adjacent to and inside OpenMP constructs.
+
+! RUN: bbc %s -fopenmp -emit-hlfir -o "-" | FileCheck %s
+
+! CHECK-LABEL: func @_QPss1{{.*}} {
+! CHECK: br ^bb1
+! CHECK: ^bb1: // 2 preds: ^bb0, ^bb4
+! CHECK: cond_br %{{[0-9]*}}, ^bb2, ^bb5
+! CHECK: ^bb2: // pred: ^bb1
+! CHECK: cond_br %{{[0-9]*}}, ^bb3, ^bb4
+! CHECK: ^bb4: // pred: ^bb2
+! CHECK: fir.call @_FortranAioBeginExternalListOutput
+! CHECK: br ^bb1
+! CHECK: ^bb5: // 2 preds: ^bb1, ^bb3
+! CHECK: omp.master {
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: omp.terminator
+! CHECK: }
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: }
+subroutine ss1(n) ! unstructured code followed by a structured OpenMP construct
+ do i = 1, 3
+ if (i .eq. n) exit
+ print*, 'ss1-A', i
+ enddo
+ !$omp master
+ print*, 'ss1-B', i
+ !$omp end master
+ print*
+end
+
+! CHECK-LABEL: func @_QPss2{{.*}} {
+! CHECK: omp.master {
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: br ^bb1
+! CHECK: ^bb1: // 2 preds: ^bb0, ^bb4
+! CHECK: cond_br %{{[0-9]*}}, ^bb2, ^bb5
+! CHECK: ^bb2: // pred: ^bb1
+! CHECK: cond_br %{{[0-9]*}}, ^bb3, ^bb4
+! CHECK: ^bb3: // pred: ^bb2
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: br ^bb1
+! CHECK: ^bb5: // 2 preds: ^bb1, ^bb3
+! CHECK: omp.terminator
+! CHECK: }
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: }
+subroutine ss2(n) ! unstructured OpenMP construct; loop exit inside construct
+ !$omp master
+ print*, 'ss2-A', n
+ do i = 1, 3
+ if (i .eq. n) exit
+ print*, 'ss2-B', i
+ enddo
+ !$omp end master
+ print*, 'ss2-C', i
+ print*
+end
+
+! CHECK-LABEL: func @_QPss3{{.*}} {
+! CHECK: omp.parallel {
+! CHECK: %[[ALLOCA_K:.*]] = fir.alloca i32 {bindc_name = "k", pinned}
+! CHECK: %[[K_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_K]] {uniq_name = "_QFss3Ek"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[ALLOCA_1:.*]] = fir.alloca i32 {{{.*}}, pinned}
+! CHECK: %[[OMP_LOOP_J_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_1]] {uniq_name = "_QFss3Ej"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: %[[ALLOCA_2:.*]] = fir.alloca i32 {{{.*}}, pinned}
+! CHECK: %[[OMP_LOOP_K_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_2]] {uniq_name = "_QFss3Ek"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: br ^bb1
+! CHECK: ^bb1: // 2 preds: ^bb0, ^bb3
+! CHECK: cond_br %{{[0-9]*}}, ^bb2, ^bb4
+! CHECK: ^bb2: // pred: ^bb1
+! CHECK: omp.wsloop for (%[[ARG1:.*]]) : {{.*}} {
+! CHECK: fir.store %[[ARG1]] to %[[OMP_LOOP_K_DECL]]#1 : !fir.ref<i32>
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: %[[LOAD_1:.*]] = fir.load %[[OMP_LOOP_K_DECL]]#0 : !fir.ref<i32>
+! CHECK: @_FortranAioOutputInteger32(%{{.*}}, %[[LOAD_1]])
+! CHECK: omp.yield
+! CHECK: }
+! CHECK: omp.wsloop for (%[[ARG2:.*]]) : {{.*}} {
+! CHECK: fir.store %[[ARG2]] to %[[OMP_LOOP_J_DECL]]#1 : !fir.ref<i32>
+! CHECK: br ^bb1
+! CHECK: ^bb2: // 2 preds: ^bb1, ^bb5
+! CHECK: cond_br %{{[0-9]*}}, ^bb3, ^bb6
+! CHECK: ^bb3: // pred: ^bb2
+! CHECK: cond_br %{{[0-9]*}}, ^bb4, ^bb5
+! CHECK: ^bb4: // pred: ^bb3
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: %[[LOAD_2:.*]] = fir.load %[[K_DECL]]#0 : !fir.ref<i32>
+! CHECK: @_FortranAioOutputInteger32(%{{.*}}, %[[LOAD_2]])
+! CHECK: br ^bb2
+! CHECK: ^bb6: // 2 preds: ^bb2, ^bb4
+! CHECK: omp.yield
+! CHECK: }
+! CHECK: br ^bb1
+! CHECK: ^bb4: // pred: ^bb1
+! CHECK: omp.terminator
+! CHECK: }
+! CHECK: }
+subroutine ss3(n) ! nested unstructured OpenMP constructs
+ !$omp parallel
+ do i = 1, 3
+ !$omp do
+ do k = 1, 3
+ print*, 'ss3-A', k
+ enddo
+ !$omp end do
+ !$omp do
+ do j = 1, 3
+ do k = 1, 3
+ if (k .eq. n) exit
+ print*, 'ss3-B', k
+ enddo
+ enddo
+ !$omp end do
+ enddo
+ !$omp end parallel
+end
+
+! CHECK-LABEL: func @_QPss4{{.*}} {
+! CHECK: omp.parallel {
+! CHECK: %[[ALLOCA:.*]] = fir.alloca i32 {{{.*}}, pinned}
+! CHECK: %[[OMP_LOOP_J_DECL:.*]]:2 = hlfir.declare %[[ALLOCA]] {uniq_name = "_QFss4Ej"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: omp.wsloop for (%[[ARG:.*]]) : {{.*}} {
+! CHECK: fir.store %[[ARG]] to %[[OMP_LOOP_J_DECL]]#1 : !fir.ref<i32>
+! CHECK: %[[COND:.*]] = arith.cmpi eq, %{{.*}}, %{{.*}}
+! CHECK: %[[COND_XOR:.*]] = arith.xori %[[COND]], %{{.*}}
+! CHECK: fir.if %[[COND_XOR]] {
+! CHECK: @_FortranAioBeginExternalListOutput
+! CHECK: %[[LOAD:.*]] = fir.load %[[OMP_LOOP_J_DECL]]#0 : !fir.ref<i32>
+! CHECK: @_FortranAioOutputInteger32(%{{.*}}, %[[LOAD]])
+! CHECK: } else {
+! CHECK: }
+! CHECK-NEXT: omp.yield
+! CHECK-NEXT: }
+! CHECK: omp.terminator
+! CHECK-NEXT:}
+subroutine ss4(n) ! CYCLE in OpenMP wsloop constructs
+ !$omp parallel
+ do i = 1, 3
+ !$omp do
+ do j = 1, 3
+ if (j .eq. n) cycle
+ print*, 'ss4', j
+ enddo
+ !$omp end do
+ enddo
+ !$omp end parallel
+end
+
+! CHECK-LABEL: func @_QPss5() {
+! CHECK: omp.parallel {
+! CHECK: omp.wsloop {{.*}} {
+! CHECK: br ^[[BB1:.*]]
+! CHECK: ^[[BB1]]:
+! CHECK: br ^[[BB2:.*]]
+! CHECK: ^[[BB2]]:
+! CHECK: cond_br %{{.*}}, ^[[BB3:.*]], ^[[BB6:.*]]
+! CHECK: ^[[BB3]]:
+! CHECK: cond_br %{{.*}}, ^[[BB4:.*]], ^[[BB3:.*]]
+! CHECK: ^[[BB4]]:
+! CHECK: br ^[[BB6]]
+! CHECK: ^[[BB3]]:
+! CHECK: br ^[[BB2]]
+! CHECK: ^[[BB6]]:
+! CHECK: omp.yield
+! CHECK: }
+! CHECK: omp.terminator
+! CHECK: }
+subroutine ss5() ! EXIT inside OpenMP wsloop (inside parallel)
+ integer :: x
+ !$omp parallel private(x)
+ !$omp do
+ do j = 1, 3
+ x = j * i
+ do k = 1, 3
+ if (k .eq. n) exit
+ x = k
+ x = x + k
+ enddo
+ x = j - 222
+ enddo
+ !$omp end do
+ !$omp end parallel
+end
+
+! CHECK-LABEL: func @_QPss6() {
+! CHECK: omp.parallel {
+! CHECK: br ^[[BB1_OUTER:.*]]
+! CHECK: ^[[BB1_OUTER]]:
+! CHECK: cond_br %{{.*}}, ^[[BB2_OUTER:.*]], ^[[BB3_OUTER:.*]]
+! CHECK: ^[[BB2_OUTER]]:
+! CHECK: omp.wsloop {{.*}} {
+! CHECK: br ^[[BB1:.*]]
+! CHECK: ^[[BB1]]:
+! CHECK: br ^[[BB2:.*]]
+! CHECK: ^[[BB2]]:
+! CHECK: cond_br %{{.*}}, ^[[BB3:.*]], ^[[BB6:.*]]
+! CHECK: ^[[BB3]]:
+! CHECK: cond_br %{{.*}}, ^[[BB4:.*]], ^[[BB5:.*]]
+! CHECK: ^[[BB4]]:
+! CHECK: br ^[[BB6]]
+! CHECK: ^[[BB5]]
+! CHECK: br ^[[BB2]]
+! CHECK: ^[[BB6]]:
+! CHECK: omp.yield
+! CHECK: }
+! CHECK: br ^[[BB1_OUTER]]
+! CHECK: ^[[BB3_OUTER]]:
+! CHECK: omp.terminator
+! CHECK: }
+subroutine ss6() ! EXIT inside OpenMP wsloop in a do loop (inside parallel)
+ integer :: x
+ !$omp parallel private(x)
+ do i = 1, 3
+ !$omp do
+ do j = 1, 3
+ x = j * i
+ do k = 1, 3
+ if (k .eq. n) exit
+ x = k
+ x = x + k
+ enddo
+ x = j - 222
+ enddo
+ !$omp end do
+ enddo
+ !$omp end parallel
+end
+
+! CHECK-LABEL: func @_QPss7() {
+! CHECK: br ^[[BB1_OUTER:.*]]
+! CHECK: ^[[BB1_OUTER]]:
+! CHECK: cond_br %{{.*}}, ^[[BB2_OUTER:.*]], ^[[BB3_OUTER:.*]]
+! CHECK-NEXT: ^[[BB2_OUTER:.*]]:
+! CHECK: omp.parallel {
+! CHECK: omp.wsloop {{.*}} {
+! CHECK: br ^[[BB1:.*]]
+! CHECK-NEXT: ^[[BB1]]:
+! CHECK: br ^[[BB2:.*]]
+! CHECK-NEXT: ^[[BB2]]:
+! CHECK: cond_br %{{.*}}, ^[[BB3:.*]], ^[[BB6:.*]]
+! CHECK-NEXT: ^[[BB3]]:
+! CHECK: cond_br %{{.*}}, ^[[BB4:.*]], ^[[BB5:.*]]
+! CHECK-NEXT: ^[[BB4]]:
+! CHECK: br ^[[BB6]]
+! CHECK-NEXT: ^[[BB5]]:
+! CHECK: br ^[[BB2]]
+! CHECK-NEXT: ^[[BB6]]:
+! CHECK: omp.yield
+! CHECK: }
+! CHECK: omp.terminator
+! CHECK: }
+! CHECK: br ^[[BB1_OUTER]]
+! CHECK-NEXT: ^[[BB3_OUTER]]:
+! CHECK-NEXT: return
+subroutine ss7() ! EXIT inside OpenMP parallel do (inside do loop)
+ integer :: x
+ do i = 1, 3
+ !$omp parallel do private(x)
+ do j = 1, 3
+ x = j * i
+ do k = 1, 3
+ if (k .eq. n) exit
+ x = k
+ x = x + k
+ enddo
+ enddo
+ !$omp end parallel do
+ enddo
+end
+
+! CHECK-LABEL: func @_QPss8() {
+! CHECK: omp.parallel {
+! CHECK: omp.wsloop {{.*}} {
+! CHECK: br ^[[BB1:.*]]
+! CHECK-NEXT: ^[[BB1]]:
+! CHECK: br ^[[BB2:.*]]
+! CHECK: ^[[BB2]]:
+! CHECK: cond_br %{{.*}}, ^[[BB3:.*]], ^[[BB6:.*]]
+! CHECK: ^[[BB3]]:
+! CHECK: cond_br %{{.*}}, ^[[BB4:.*]], ^[[BB5:.*]]
+! CHECK: ^[[BB4]]:
+! CHECK-NEXT: br ^[[BB6]]
+! CHECK: ^[[BB5]]:
+! CHECK: br ^[[BB2]]
+! CHECK-NEXT: ^[[BB6]]:
+! CHECK: omp.yield
+! CHECK: }
+! CHECK: omp.terminator
+! CHECK: }
+subroutine ss8() ! EXIT inside OpenMP parallel do
+ integer :: x
+ !$omp parallel do private(x)
+ do j = 1, 3
+ x = j * i
+ do k = 1, 3
+ if (k .eq. n) exit
+ x = k
+ x = x + k
+ enddo
+ enddo
+ !$omp end parallel do
+end
+
+! CHECK-LABEL: func @_QPss9() {
+! CHECK: omp.parallel {
+! CHECK-NEXT: omp.parallel {
+! CHECK: br ^[[BB1:.*]]
+! CHECK: ^[[BB1]]:
+! CHECK: cond_br %{{.*}}, ^[[BB2:.*]], ^[[BB5:.*]]
+! CHECK-NEXT: ^[[BB2]]:
+! CHECK: cond_br %{{.*}}, ^[[BB3:.*]], ^[[BB4:.*]]
+! CHECK-NEXT: ^[[BB3]]:
+! CHECK-NEXT: br ^[[BB5]]
+! CHECK-NEXT: ^[[BB4]]:
+! CHECK: br ^[[BB1]]
+! CHECK-NEXT: ^[[BB5]]:
+! CHECK: omp.terminator
+! CHECK-NEXT: }
+! CHECK: omp.terminator
+! CHECK-NEXT }
+! CHECK: }
+subroutine ss9() ! EXIT inside OpenMP parallel (inside parallel)
+ integer :: x
+ !$omp parallel
+ !$omp parallel private(x)
+ do k = 1, 3
+ if (k .eq. n) exit
+ x = k
+ x = x + k
+ end do
+ !$omp end parallel
+ !$omp end parallel
+end
+
+! CHECK-LABEL: func @_QQmain
+program p
+ call ss1(2)
+ call ss2(2)
+ call ss3(2)
+ call ss4(2)
+ call ss5()
+ call ss6()
+ call ss7()
+ call ss8()
+ call ss9()
+end
diff --git a/flang/test/Lower/OpenMP/wsloop.f90 b/flang/test/Lower/OpenMP/wsloop.f90
new file mode 100644
index 000000000000000..4068f715c3e189a
--- /dev/null
+++ b/flang/test/Lower/OpenMP/wsloop.f90
@@ -0,0 +1,75 @@
+! This test checks lowering of OpenMP DO Directive (Worksharing).
+
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+
+!CHECK-LABEL: func @_QPsimple_loop()
+subroutine simple_loop
+ integer :: i
+ ! CHECK: omp.parallel
+ !$OMP PARALLEL
+ ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned}
+ ! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loopEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+ ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
+ ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
+ ! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
+ ! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
+ !$OMP DO
+ do i=1, 9
+ ! CHECK: fir.store %[[I]] to %[[IV_DECL:.*]]#1 : !fir.ref<i32>
+ ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32>
+ ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
+ print*, i
+ end do
+ ! CHECK: omp.yield
+ !$OMP END DO
+ ! CHECK: omp.terminator
+ !$OMP END PARALLEL
+end subroutine
+
+!CHECK-LABEL: func @_QPsimple_loop_with_step()
+subroutine simple_loop_with_step
+ integer :: i
+ ! CHECK: omp.parallel
+ !$OMP PARALLEL
+ ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned}
+ ! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loop_with_stepEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+ ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
+ ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
+ ! CHECK: %[[WS_STEP:.*]] = arith.constant 2 : i32
+ ! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
+ ! CHECK: fir.store %[[I]] to %[[IV_DECL]]#1 : !fir.ref<i32>
+ ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32>
+ !$OMP DO
+ do i=1, 9, 2
+ ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
+ print*, i
+ end do
+ ! CHECK: omp.yield
+ !$OMP END DO
+ ! CHECK: omp.terminator
+ !$OMP END PARALLEL
+end subroutine
+
+!CHECK-LABEL: func @_QPloop_with_schedule_nowait()
+subroutine loop_with_schedule_nowait
+ integer :: i
+ ! CHECK: omp.parallel
+ !$OMP PARALLEL
+ ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned}
+ ! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFloop_with_schedule_nowaitEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+ ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
+ ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
+ ! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
+ ! CHECK: omp.wsloop schedule(runtime) nowait for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
+ !$OMP DO SCHEDULE(runtime)
+ do i=1, 9
+ ! CHECK: fir.store %[[I]] to %[[IV_DECL]]#1 : !fir.ref<i32>
+ ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32>
+ ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
+ print*, i
+ end do
+ ! CHECK: omp.yield
+ !$OMP END DO NOWAIT
+ ! CHECK: omp.terminator
+ !$OMP END PARALLEL
+end subroutine
More information about the flang-commits
mailing list