[flang-commits] [flang] [Flang][OpenMP][Lower] Add lowering support of OpenMP distribute to MLIR (PR #67798)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Wed Jan 31 04:17:08 PST 2024
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/67798
>From cab5085363f43af8c23b5383b4be74faff774e5a Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Thu, 28 Sep 2023 13:47:06 +0100
Subject: [PATCH 1/3] [Flang][Lower] Add lowering support of OpenMP distribute
to MLIR
This patch adds support for lowering the OpenMP distribute directive from PFT
to MLIR. This in turn unlocks support for several related combined loop
constructs as well.
---
flang/lib/Lower/OpenMP.cpp | 41 +-
flang/test/Lower/OpenMP/FIR/if-clause.f90 | 902 +++++++++++++++++-
flang/test/Lower/OpenMP/FIR/loop-combined.f90 | 162 +++-
flang/test/Lower/OpenMP/distribute.f90 | 117 +++
flang/test/Lower/OpenMP/if-clause.f90 | 902 +++++++++++++++++-
flang/test/Lower/OpenMP/loop-combined.f90 | 162 +++-
6 files changed, 2181 insertions(+), 105 deletions(-)
create mode 100644 flang/test/Lower/OpenMP/distribute.f90
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index be2117efbabc0..699f3c217530f 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -568,6 +568,9 @@ class ClauseProcessor {
bool processDevice(Fortran::lower::StatementContext &stmtCtx,
mlir::Value &result) const;
bool processDeviceType(mlir::omp::DeclareTargetDeviceType &result) const;
+ bool processDistSchedule(Fortran::lower::StatementContext &stmtCtx,
+ mlir::UnitAttr &scheduleStatic,
+ mlir::Value &chunkSize) const;
bool processFinal(Fortran::lower::StatementContext &stmtCtx,
mlir::Value &result) const;
bool processHint(mlir::IntegerAttr &result) const;
@@ -1493,6 +1496,19 @@ bool ClauseProcessor::processDeviceType(
return false;
}
+bool ClauseProcessor::processDistSchedule(
+ Fortran::lower::StatementContext &stmtCtx, mlir::UnitAttr &scheduleStatic,
+ mlir::Value &chunkSize) const {
+ if (auto *distScheduleClause = findUniqueClause<ClauseTy::DistSchedule>()) {
+ scheduleStatic = converter.getFirOpBuilder().getUnitAttr();
+ if (const auto *expr = Fortran::semantics::GetExpr(distScheduleClause->v)) {
+ chunkSize = fir::getBase(converter.genExprValue(*expr, stmtCtx));
+ }
+ return true;
+ }
+ return false;
+}
+
bool ClauseProcessor::processFinal(Fortran::lower::StatementContext &stmtCtx,
mlir::Value &result) const {
const Fortran::parser::CharBlock *source = nullptr;
@@ -3003,6 +3019,27 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
reductionDeclSymbols));
}
+static mlir::omp::DistributeOp
+genDistributeOp(Fortran::lower::AbstractConverter &converter,
+ Fortran::lower::pft::Evaluation &eval, bool genNested,
+ mlir::Location currentLocation,
+ const Fortran::parser::OmpClauseList &clauseList,
+ bool outerCombined = false) {
+ Fortran::lower::StatementContext stmtCtx;
+ mlir::UnitAttr scheduleStatic;
+ mlir::Value chunkSize;
+ llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands;
+
+ ClauseProcessor cp(converter, clauseList);
+ cp.processDistSchedule(stmtCtx, scheduleStatic, chunkSize);
+ cp.processAllocate(allocatorOperands, allocateOperands);
+
+ return genOpWithBody<mlir::omp::DistributeOp>(
+ converter, eval, genNested, currentLocation, outerCombined, &clauseList,
+ scheduleStatic, chunkSize, allocateOperands, allocatorOperands,
+ /*order_val=*/nullptr);
+}
+
/// Extract the list of function and variable symbols affected by the given
/// 'declare target' directive and return the intended device type for them.
static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
@@ -3387,7 +3424,9 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
}
if (llvm::omp::allDistributeSet.test(ompDirective)) {
validDirective = true;
- TODO(currentLocation, "Distribute construct");
+ bool outerCombined = llvm::omp::topDistributeSet.test(ompDirective);
+ genDistributeOp(converter, eval, /*genNested=*/false, currentLocation,
+ loopOpClauseList, outerCombined);
}
if ((llvm::omp::allParallelSet & llvm::omp::loopConstructSet)
.test(ompDirective)) {
diff --git a/flang/test/Lower/OpenMP/FIR/if-clause.f90 b/flang/test/Lower/OpenMP/FIR/if-clause.f90
index a1235be8e61ea..eba4aa06fb9b3 100644
--- a/flang/test/Lower/OpenMP/FIR/if-clause.f90
+++ b/flang/test/Lower/OpenMP/FIR/if-clause.f90
@@ -7,23 +7,147 @@ program main
integer :: i
! TODO When they are supported, add tests for:
- ! - DISTRIBUTE PARALLEL DO
- ! - DISTRIBUTE PARALLEL DO SIMD
- ! - DISTRIBUTE SIMD
! - PARALLEL SECTIONS
! - PARALLEL WORKSHARE
- ! - TARGET PARALLEL
- ! - TARGET TEAMS DISTRIBUTE
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TARGET TEAMS DISTRIBUTE SIMD
! - TARGET UPDATE
! - TASKLOOP
! - TASKLOOP SIMD
- ! - TEAMS DISTRIBUTE
- ! - TEAMS DISTRIBUTE PARALLEL DO
- ! - TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TEAMS DISTRIBUTE SIMD
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do simd if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute simd
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ !$omp end teams
! ----------------------------------------------------------------------------
! DO SIMD
@@ -354,6 +478,53 @@ program main
end do
!$omp end target parallel do simd
+ ! ----------------------------------------------------------------------------
+ ! TARGET PARALLEL
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel if(.true.)
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel if(target: .true.) if(parallel: .false.)
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel if(target: .true.)
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel if(parallel: .true.)
+ i = 1
+ !$omp end target parallel
+
! ----------------------------------------------------------------------------
! TARGET SIMD
! ----------------------------------------------------------------------------
@@ -407,71 +578,724 @@ program main
!$omp end target simd
! ----------------------------------------------------------------------------
- ! TARGET TEAMS
+ ! TARGET TEAMS DISTRIBUTE
! ----------------------------------------------------------------------------
-
! CHECK: omp.target
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
! CHECK: omp.teams
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- !$omp target teams
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-SAME: if({{.*}})
! CHECK: omp.teams
! CHECK-SAME: if({{.*}})
- !$omp target teams if(.true.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-SAME: if({{.*}})
! CHECK: omp.teams
! CHECK-SAME: if({{.*}})
- !$omp target teams if(target: .true.) if(teams: .false.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(target: .true.) if(teams: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-SAME: if({{.*}})
! CHECK: omp.teams
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- !$omp target teams if(target: .true.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
! CHECK: omp.teams
! CHECK-SAME: if({{.*}})
- !$omp target teams if(teams: .true.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! ----------------------------------------------------------------------------
- ! TASK
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO
! ----------------------------------------------------------------------------
- ! CHECK: omp.task
+ ! CHECK: omp.target
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- !$omp task
- !$omp end task
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
- ! CHECK: omp.task
+ ! CHECK: omp.target
! CHECK-SAME: if({{.*}})
- !$omp task if(.true.)
- !$omp end task
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
- ! CHECK: omp.task
+ ! CHECK: omp.target
! CHECK-SAME: if({{.*}})
- !$omp task if(task: .true.)
- !$omp end task
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do if(target: .true.) if(teams: .false.) if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do simd if(target: .true.) if(teams: .false.) if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute simd if(target: .true.) if(teams: .false.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute simd if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(.true.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(target: .true.) if(teams: .false.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams if(target: .true.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(teams: .true.)
+ i = 1
+ !$omp end target teams
+
+ ! ----------------------------------------------------------------------------
+ ! TASK
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.task
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp task
+ !$omp end task
+
+ ! CHECK: omp.task
+ ! CHECK-SAME: if({{.*}})
+ !$omp task if(.true.)
+ !$omp end task
+
+ ! CHECK: omp.task
+ ! CHECK-SAME: if({{.*}})
+ !$omp task if(task: .true.)
+ !$omp end task
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do if(teams: .true.) if(parallel: .false.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do simd if(teams: .false.) if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute simd if(teams: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
! ----------------------------------------------------------------------------
! TEAMS
diff --git a/flang/test/Lower/OpenMP/FIR/loop-combined.f90 b/flang/test/Lower/OpenMP/FIR/loop-combined.f90
index a6cec1beb49c8..fe76c9ea4ba93 100644
--- a/flang/test/Lower/OpenMP/FIR/loop-combined.f90
+++ b/flang/test/Lower/OpenMP/FIR/loop-combined.f90
@@ -6,19 +6,51 @@
program main
integer :: i
- ! TODO When DISTRIBUTE, TASKLOOP and TEAMS are supported add:
- ! - DISTRIBUTE PARALLEL DO SIMD
- ! - DISTRIBUTE PARALLEL DO
- ! - DISTRIBUTE SIMD
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO
- ! - TARGET TEAMS DISTRIBUTE SIMD
- ! - TARGET TEAMS DISTRIBUTE
- ! - TASKLOOP SIMD
- ! - TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TEAMS DISTRIBUTE PARALLEL DO
- ! - TEAMS DISTRIBUTE SIMD
- ! - TEAMS DISTRIBUTE
+ ! TODO TASKLOOP SIMD
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK: omp.simdloop
+ !$omp distribute simd
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ !$omp end teams
! ----------------------------------------------------------------------------
! DO SIMD
@@ -71,6 +103,60 @@ program main
end do
!$omp end target parallel do
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp target teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp target teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.simdloop
+ !$omp target teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.wsloop
+ !$omp target teams distribute
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
+
! ----------------------------------------------------------------------------
! TARGET SIMD
! ----------------------------------------------------------------------------
@@ -80,4 +166,54 @@ program main
do i = 1, 10
end do
!$omp end target simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.simdloop
+ !$omp teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.wsloop
+ !$omp teams distribute
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
end program main
diff --git a/flang/test/Lower/OpenMP/distribute.f90 b/flang/test/Lower/OpenMP/distribute.f90
new file mode 100644
index 0000000000000..dcfdeb25ded93
--- /dev/null
+++ b/flang/test/Lower/OpenMP/distribute.f90
@@ -0,0 +1,117 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+! CHECK-LABEL: func @_QPdistribute_simple
+subroutine distribute_simple()
+ ! CHECK: omp.teams
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ !$omp distribute
+
+ ! CHECK: omp.wsloop
+ do i = 1, 10
+ call foo()
+ ! CHECK: omp.yield
+ end do
+
+ ! CHECK: omp.terminator
+ !$omp end distribute
+
+ ! CHECK: omp.terminator
+ !$omp end teams
+end subroutine distribute_simple
+
+!===============================================================================
+! `dist_schedule` clause
+!===============================================================================
+
+! CHECK-LABEL: func @_QPdistribute_dist_schedule
+! CHECK-SAME: %[[X_ARG:.*]]: !fir.ref<i32>
+subroutine distribute_dist_schedule(x)
+ ! CHECK: %[[X_REF:.*]]:2 = hlfir.declare %[[X_ARG]]
+ integer, intent(in) :: x
+
+ ! CHECK: omp.teams
+ !$omp teams
+
+ ! STATIC SCHEDULE, CONSTANT CHUNK SIZE
+
+ ! CHECK: %[[CONST_CHUNK_SIZE:.*]] = arith.constant 5 : i32
+ ! CHECK: omp.distribute
+ ! CHECK-SAME: dist_schedule_static
+ ! CHECK-SAME: chunk_size(%[[CONST_CHUNK_SIZE]] : i32)
+ !$omp distribute dist_schedule(static, 5)
+
+ ! CHECK: omp.wsloop
+ do i = 1, 10
+ call foo()
+ ! CHECK: omp.yield
+ end do
+
+ ! CHECK: omp.terminator
+ !$omp end distribute
+
+ ! STATIC SCHEDULE, VARIABLE CHUNK SIZE
+
+ ! CHECK: %[[X:.*]] = fir.load %[[X_REF]]#0
+ ! CHECK: omp.distribute
+ ! CHECK-SAME: dist_schedule_static
+ ! CHECK-SAME: chunk_size(%[[X]] : i32)
+ !$omp distribute dist_schedule(static, x)
+
+ ! CHECK: omp.wsloop
+ do i = 1, 10
+ call foo()
+ ! CHECK: omp.yield
+ end do
+
+ ! CHECK: omp.terminator
+ !$omp end distribute
+
+ ! STATIC SCHEDULE, NO CHUNK SIZE
+
+ ! CHECK: omp.distribute
+ ! CHECK-SAME: dist_schedule_static
+ ! CHECK-NOT: chunk_size
+ !$omp distribute dist_schedule(static)
+
+ ! CHECK: omp.wsloop
+ do i = 1, 10
+ call foo()
+ ! CHECK: omp.yield
+ end do
+
+ ! CHECK: omp.terminator
+ !$omp end distribute
+
+ ! CHECK: omp.terminator
+ !$omp end teams
+end subroutine distribute_dist_schedule
+
+!===============================================================================
+! `allocate` clause
+!===============================================================================
+
+! CHECK-LABEL: func @_QPdistribute_allocate
+subroutine distribute_allocate()
+ use omp_lib
+ integer :: x
+ ! CHECK: omp.teams
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-SAME: allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>)
+ !$omp distribute allocate(omp_high_bw_mem_alloc: x) private(x)
+
+ ! CHECK: omp.wsloop
+ do i = 1, 10
+ x = i
+ ! CHECK: omp.yield
+ end do
+
+ ! CHECK: omp.terminator
+ !$omp end distribute
+
+ ! CHECK: omp.terminator
+ !$omp end teams
+end subroutine distribute_allocate
diff --git a/flang/test/Lower/OpenMP/if-clause.f90 b/flang/test/Lower/OpenMP/if-clause.f90
index f982bf67b0722..ba63f0554dd7a 100644
--- a/flang/test/Lower/OpenMP/if-clause.f90
+++ b/flang/test/Lower/OpenMP/if-clause.f90
@@ -7,23 +7,147 @@ program main
integer :: i
! TODO When they are supported, add tests for:
- ! - DISTRIBUTE PARALLEL DO
- ! - DISTRIBUTE PARALLEL DO SIMD
- ! - DISTRIBUTE SIMD
! - PARALLEL SECTIONS
! - PARALLEL WORKSHARE
- ! - TARGET PARALLEL
- ! - TARGET TEAMS DISTRIBUTE
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TARGET TEAMS DISTRIBUTE SIMD
! - TARGET UPDATE
! - TASKLOOP
! - TASKLOOP SIMD
- ! - TEAMS DISTRIBUTE
- ! - TEAMS DISTRIBUTE PARALLEL DO
- ! - TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TEAMS DISTRIBUTE SIMD
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do simd if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp distribute simd
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp distribute simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ !$omp end teams
! ----------------------------------------------------------------------------
! DO SIMD
@@ -354,6 +478,53 @@ program main
end do
!$omp end target parallel do simd
+ ! ----------------------------------------------------------------------------
+ ! TARGET PARALLEL
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel if(.true.)
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel if(target: .true.) if(parallel: .false.)
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target parallel if(target: .true.)
+ i = 1
+ !$omp end target parallel
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target parallel if(parallel: .true.)
+ i = 1
+ !$omp end target parallel
+
! ----------------------------------------------------------------------------
! TARGET SIMD
! ----------------------------------------------------------------------------
@@ -407,71 +578,724 @@ program main
!$omp end target simd
! ----------------------------------------------------------------------------
- ! TARGET TEAMS
+ ! TARGET TEAMS DISTRIBUTE
! ----------------------------------------------------------------------------
-
! CHECK: omp.target
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
! CHECK: omp.teams
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- !$omp target teams
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-SAME: if({{.*}})
! CHECK: omp.teams
! CHECK-SAME: if({{.*}})
- !$omp target teams if(.true.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-SAME: if({{.*}})
! CHECK: omp.teams
! CHECK-SAME: if({{.*}})
- !$omp target teams if(target: .true.) if(teams: .false.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(target: .true.) if(teams: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-SAME: if({{.*}})
! CHECK: omp.teams
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- !$omp target teams if(target: .true.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! CHECK: omp.target
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
! CHECK: omp.teams
! CHECK-SAME: if({{.*}})
- !$omp target teams if(teams: .true.)
- i = 1
- !$omp end target teams
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
! ----------------------------------------------------------------------------
- ! TASK
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO
! ----------------------------------------------------------------------------
- ! CHECK: omp.task
+ ! CHECK: omp.target
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- !$omp task
- !$omp end task
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
- ! CHECK: omp.task
+ ! CHECK: omp.target
! CHECK-SAME: if({{.*}})
- !$omp task if(.true.)
- !$omp end task
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
- ! CHECK: omp.task
+ ! CHECK: omp.target
! CHECK-SAME: if({{.*}})
- !$omp task if(task: .true.)
- !$omp end task
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do if(target: .true.) if(teams: .false.) if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do simd if(target: .true.) if(teams: .false.) if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute simd if(target: .true.) if(teams: .false.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute simd if(target: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams distribute simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams distribute simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(.true.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(target: .true.) if(teams: .false.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp target teams if(target: .true.)
+ i = 1
+ !$omp end target teams
+
+ ! CHECK: omp.target
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ !$omp target teams if(teams: .true.)
+ i = 1
+ !$omp end target teams
+
+ ! ----------------------------------------------------------------------------
+ ! TASK
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.task
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp task
+ !$omp end task
+
+ ! CHECK: omp.task
+ ! CHECK-SAME: if({{.*}})
+ !$omp task if(.true.)
+ !$omp end task
+
+ ! CHECK: omp.task
+ ! CHECK-SAME: if({{.*}})
+ !$omp task if(task: .true.)
+ !$omp end task
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do if(teams: .true.) if(parallel: .false.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do simd if(teams: .false.) if(parallel: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute parallel do simd if(parallel: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.parallel
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute parallel do simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute simd if(.true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute simd if(teams: .true.) if(simd: .false.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ !$omp teams distribute simd if(teams: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! CHECK: omp.teams
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.distribute
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
+ ! CHECK: omp.simdloop
+ ! CHECK-SAME: if({{.*}})
+ !$omp teams distribute simd if(simd: .true.)
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
! ----------------------------------------------------------------------------
! TEAMS
diff --git a/flang/test/Lower/OpenMP/loop-combined.f90 b/flang/test/Lower/OpenMP/loop-combined.f90
index 70488b6a769ce..5f0858a295624 100644
--- a/flang/test/Lower/OpenMP/loop-combined.f90
+++ b/flang/test/Lower/OpenMP/loop-combined.f90
@@ -6,19 +6,51 @@
program main
integer :: i
- ! TODO When DISTRIBUTE, TASKLOOP and TEAMS are supported add:
- ! - DISTRIBUTE PARALLEL DO SIMD
- ! - DISTRIBUTE PARALLEL DO
- ! - DISTRIBUTE SIMD
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TARGET TEAMS DISTRIBUTE PARALLEL DO
- ! - TARGET TEAMS DISTRIBUTE SIMD
- ! - TARGET TEAMS DISTRIBUTE
- ! - TASKLOOP SIMD
- ! - TEAMS DISTRIBUTE PARALLEL DO SIMD
- ! - TEAMS DISTRIBUTE PARALLEL DO
- ! - TEAMS DISTRIBUTE SIMD
- ! - TEAMS DISTRIBUTE
+ ! TODO TASKLOOP SIMD
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do simd
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end distribute parallel do
+
+ !$omp end teams
+
+ ! ----------------------------------------------------------------------------
+ ! DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+ !$omp teams
+
+ ! CHECK: omp.distribute
+ ! CHECK: omp.simdloop
+ !$omp distribute simd
+ do i = 1, 10
+ end do
+ !$omp end distribute simd
+
+ !$omp end teams
! ----------------------------------------------------------------------------
! DO SIMD
@@ -71,6 +103,60 @@ program main
end do
!$omp end target parallel do
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp target teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp target teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.simdloop
+ !$omp target teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute simd
+
+ ! ----------------------------------------------------------------------------
+ ! TARGET TEAMS DISTRIBUTE
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.target
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.wsloop
+ !$omp target teams distribute
+ do i = 1, 10
+ end do
+ !$omp end target teams distribute
+
! ----------------------------------------------------------------------------
! TARGET SIMD
! ----------------------------------------------------------------------------
@@ -80,4 +166,54 @@ program main
do i = 1, 10
end do
!$omp end target simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.simdloop
+ !$omp teams distribute parallel do simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE PARALLEL DO
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.parallel
+ ! CHECK: omp.wsloop
+ !$omp teams distribute parallel do
+ do i = 1, 10
+ end do
+ !$omp end teams distribute parallel do
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE SIMD
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.simdloop
+ !$omp teams distribute simd
+ do i = 1, 10
+ end do
+ !$omp end teams distribute simd
+
+ ! ----------------------------------------------------------------------------
+ ! TEAMS DISTRIBUTE
+ ! ----------------------------------------------------------------------------
+
+ ! CHECK: omp.teams
+ ! CHECK: omp.distribute
+ ! CHECK: omp.wsloop
+ !$omp teams distribute
+ do i = 1, 10
+ end do
+ !$omp end teams distribute
end program main
>From cab2249cda2e5b84a4965a19bf04301481421bcb Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Fri, 26 Jan 2024 11:46:45 +0000
Subject: [PATCH 2/3] Remove braces
---
flang/lib/Lower/OpenMP.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 699f3c217530f..4b8ed9b83a028 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -1501,9 +1501,8 @@ bool ClauseProcessor::processDistSchedule(
mlir::Value &chunkSize) const {
if (auto *distScheduleClause = findUniqueClause<ClauseTy::DistSchedule>()) {
scheduleStatic = converter.getFirOpBuilder().getUnitAttr();
- if (const auto *expr = Fortran::semantics::GetExpr(distScheduleClause->v)) {
+ if (const auto *expr = Fortran::semantics::GetExpr(distScheduleClause->v))
chunkSize = fir::getBase(converter.genExprValue(*expr, stmtCtx));
- }
return true;
}
return false;
>From 63295bcd3432a7f80f647756e35e5ffb9aaacc3f Mon Sep 17 00:00:00 2001
From: Sergio Afonso <safonsof at amd.com>
Date: Wed, 31 Jan 2024 12:15:39 +0000
Subject: [PATCH 3/3] Update tests
---
flang/test/Lower/OpenMP/FIR/if-clause.f90 | 84 ++++++++++++-------
flang/test/Lower/OpenMP/FIR/loop-combined.f90 | 6 +-
flang/test/Lower/OpenMP/if-clause.f90 | 80 ++++++++++++------
flang/test/Lower/OpenMP/loop-combined.f90 | 6 +-
4 files changed, 114 insertions(+), 62 deletions(-)
diff --git a/flang/test/Lower/OpenMP/FIR/if-clause.f90 b/flang/test/Lower/OpenMP/FIR/if-clause.f90
index eba4aa06fb9b3..8c9750c1b165d 100644
--- a/flang/test/Lower/OpenMP/FIR/if-clause.f90
+++ b/flang/test/Lower/OpenMP/FIR/if-clause.f90
@@ -1,7 +1,7 @@
! This test checks lowering of OpenMP IF clauses.
-! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
-! RUN: %flang_fc1 -fopenmp -emit-fir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
program main
integer :: i
@@ -12,6 +12,7 @@ program main
! - TARGET UPDATE
! - TASKLOOP
! - TASKLOOP SIMD
+ ! TODO Update worksharing-loop SIMD tests to expect 'if' clause
! ----------------------------------------------------------------------------
! DISTRIBUTE PARALLEL DO SIMD
@@ -23,7 +24,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp distribute parallel do simd
@@ -35,8 +36,9 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp distribute parallel do simd if(.true.)
do i = 1, 10
end do
@@ -46,8 +48,9 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp distribute parallel do simd if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -57,7 +60,7 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp distribute parallel do simd if(parallel: .true.)
@@ -70,8 +73,9 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp distribute parallel do simd if(simd: .true.)
do i = 1, 10
end do
@@ -161,12 +165,16 @@ program main
!$omp end do simd
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp do simd if(.true.)
do i = 1, 10
end do
!$omp end do simd
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp do simd if(simd: .true.)
do i = 1, 10
end do
@@ -236,6 +244,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp parallel do simd if(.true.)
do i = 1, 10
end do
@@ -244,6 +254,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp parallel do simd if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -263,6 +275,8 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp parallel do simd if(simd: .true.)
do i = 1, 10
end do
@@ -438,6 +452,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target parallel do simd if(.true.)
do i = 1, 10
end do
@@ -448,6 +464,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target parallel do simd if(target: .true.) if(parallel: .false.) &
!$omp& if(simd: .true.)
do i = 1, 10
@@ -473,6 +491,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target parallel do simd if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -755,7 +775,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd
@@ -772,8 +792,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(.true.)
do i = 1, 10
end do
@@ -788,8 +809,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(target: .true.) if(teams: .false.) if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -806,7 +828,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(target: .true.)
@@ -825,7 +847,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(teams: .true.)
@@ -844,7 +866,7 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(parallel: .true.)
@@ -864,8 +886,9 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(simd: .true.)
do i = 1, 10
end do
@@ -1146,7 +1169,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp teams distribute parallel do simd
@@ -1161,8 +1184,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp teams distribute parallel do simd if(.true.)
do i = 1, 10
end do
@@ -1175,8 +1199,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp teams distribute parallel do simd if(teams: .false.) if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -1190,7 +1215,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp teams distribute parallel do simd if(teams: .true.)
@@ -1206,7 +1231,7 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp teams distribute parallel do simd if(parallel: .true.)
@@ -1223,8 +1248,9 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp teams distribute parallel do simd if(simd: .true.)
do i = 1, 10
end do
diff --git a/flang/test/Lower/OpenMP/FIR/loop-combined.f90 b/flang/test/Lower/OpenMP/FIR/loop-combined.f90
index fe76c9ea4ba93..98291539eeb92 100644
--- a/flang/test/Lower/OpenMP/FIR/loop-combined.f90
+++ b/flang/test/Lower/OpenMP/FIR/loop-combined.f90
@@ -15,7 +15,7 @@ program main
! CHECK: omp.distribute
! CHECK: omp.parallel
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
!$omp distribute parallel do simd
do i = 1, 10
end do
@@ -111,7 +111,7 @@ program main
! CHECK: omp.teams
! CHECK: omp.distribute
! CHECK: omp.parallel
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
!$omp target teams distribute parallel do simd
do i = 1, 10
end do
@@ -174,7 +174,7 @@ program main
! CHECK: omp.teams
! CHECK: omp.distribute
! CHECK: omp.parallel
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
!$omp teams distribute parallel do simd
do i = 1, 10
end do
diff --git a/flang/test/Lower/OpenMP/if-clause.f90 b/flang/test/Lower/OpenMP/if-clause.f90
index ba63f0554dd7a..8c9750c1b165d 100644
--- a/flang/test/Lower/OpenMP/if-clause.f90
+++ b/flang/test/Lower/OpenMP/if-clause.f90
@@ -12,6 +12,7 @@ program main
! - TARGET UPDATE
! - TASKLOOP
! - TASKLOOP SIMD
+ ! TODO Update worksharing-loop SIMD tests to expect 'if' clause
! ----------------------------------------------------------------------------
! DISTRIBUTE PARALLEL DO SIMD
@@ -23,7 +24,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp distribute parallel do simd
@@ -35,8 +36,9 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp distribute parallel do simd if(.true.)
do i = 1, 10
end do
@@ -46,8 +48,9 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp distribute parallel do simd if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -57,7 +60,7 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp distribute parallel do simd if(parallel: .true.)
@@ -70,8 +73,9 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp distribute parallel do simd if(simd: .true.)
do i = 1, 10
end do
@@ -161,12 +165,16 @@ program main
!$omp end do simd
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp do simd if(.true.)
do i = 1, 10
end do
!$omp end do simd
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp do simd if(simd: .true.)
do i = 1, 10
end do
@@ -236,6 +244,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp parallel do simd if(.true.)
do i = 1, 10
end do
@@ -244,6 +254,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp parallel do simd if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -263,6 +275,8 @@ program main
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp parallel do simd if(simd: .true.)
do i = 1, 10
end do
@@ -438,6 +452,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target parallel do simd if(.true.)
do i = 1, 10
end do
@@ -448,6 +464,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target parallel do simd if(target: .true.) if(parallel: .false.) &
!$omp& if(simd: .true.)
do i = 1, 10
@@ -473,6 +491,8 @@ program main
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target parallel do simd if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -755,7 +775,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd
@@ -772,8 +792,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(.true.)
do i = 1, 10
end do
@@ -788,8 +809,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(target: .true.) if(teams: .false.) if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -806,7 +828,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(target: .true.)
@@ -825,7 +847,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(teams: .true.)
@@ -844,7 +866,7 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(parallel: .true.)
@@ -864,8 +886,9 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp target teams distribute parallel do simd if(simd: .true.)
do i = 1, 10
end do
@@ -1146,7 +1169,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp teams distribute parallel do simd
@@ -1161,8 +1184,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp teams distribute parallel do simd if(.true.)
do i = 1, 10
end do
@@ -1175,8 +1199,9 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp teams distribute parallel do simd if(teams: .false.) if(parallel: .true.) if(simd: .false.)
do i = 1, 10
end do
@@ -1190,7 +1215,7 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp teams distribute parallel do simd if(teams: .true.)
@@ -1206,7 +1231,7 @@ program main
! CHECK-SAME: {
! CHECK: omp.parallel
! CHECK-SAME: if({{.*}})
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
!$omp teams distribute parallel do simd if(parallel: .true.)
@@ -1223,8 +1248,9 @@ program main
! CHECK: omp.parallel
! CHECK-NOT: if({{.*}})
! CHECK-SAME: {
- ! CHECK: omp.simdloop
- ! CHECK-SAME: if({{.*}})
+ ! CHECK: omp.wsloop
+ ! CHECK-NOT: if({{.*}})
+ ! CHECK-SAME: {
!$omp teams distribute parallel do simd if(simd: .true.)
do i = 1, 10
end do
diff --git a/flang/test/Lower/OpenMP/loop-combined.f90 b/flang/test/Lower/OpenMP/loop-combined.f90
index 5f0858a295624..87a1c657744eb 100644
--- a/flang/test/Lower/OpenMP/loop-combined.f90
+++ b/flang/test/Lower/OpenMP/loop-combined.f90
@@ -15,7 +15,7 @@ program main
! CHECK: omp.distribute
! CHECK: omp.parallel
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
!$omp distribute parallel do simd
do i = 1, 10
end do
@@ -111,7 +111,7 @@ program main
! CHECK: omp.teams
! CHECK: omp.distribute
! CHECK: omp.parallel
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
!$omp target teams distribute parallel do simd
do i = 1, 10
end do
@@ -174,7 +174,7 @@ program main
! CHECK: omp.teams
! CHECK: omp.distribute
! CHECK: omp.parallel
- ! CHECK: omp.simdloop
+ ! CHECK: omp.wsloop
!$omp teams distribute parallel do simd
do i = 1, 10
end do
More information about the flang-commits
mailing list