[flang-commits] [flang] cace715 - [Flang][OpenMP] Process reduction only once for parallel do (#70844)
via flang-commits
flang-commits at lists.llvm.org
Thu Nov 9 06:11:51 PST 2023
Author: Kiran Chandramohan
Date: 2023-11-09T14:11:46Z
New Revision: cace7159caee9e20f6a1a4fbfb70d71430986f4b
URL: https://github.com/llvm/llvm-project/commit/cace7159caee9e20f6a1a4fbfb70d71430986f4b
DIFF: https://github.com/llvm/llvm-project/commit/cace7159caee9e20f6a1a4fbfb70d71430986f4b.diff
LOG: [Flang][OpenMP] Process reduction only once for parallel do (#70844)
Added:
flang/test/Lower/OpenMP/parallel-wsloop-reduction.f90
Modified:
flang/lib/Lower/OpenMP.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index c2568c629e521c1..8380bb0717aafc2 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -2312,7 +2312,8 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
cp.processProcBind(procBindKindAttr);
cp.processDefault();
cp.processAllocate(allocatorOperands, allocateOperands);
- cp.processReduction(currentLocation, reductionVars, reductionDeclSymbols);
+ if (!outerCombined)
+ cp.processReduction(currentLocation, reductionVars, reductionDeclSymbols);
return genOpWithBody<mlir::omp::ParallelOp>(
converter, eval, currentLocation, outerCombined, &clauseList,
diff --git a/flang/test/Lower/OpenMP/parallel-wsloop-reduction.f90 b/flang/test/Lower/OpenMP/parallel-wsloop-reduction.f90
new file mode 100644
index 000000000000000..c13ec2bc4aec82a
--- /dev/null
+++ b/flang/test/Lower/OpenMP/parallel-wsloop-reduction.f90
@@ -0,0 +1,16 @@
+! Check that for parallel do, reduction is only processed for the loop
+
+! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: flang-new -fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
+
+! CHECK: omp.parallel {
+! CHECK: omp.wsloop reduction(@add_reduction_i_32
+subroutine sb
+ integer :: x
+ x = 0
+ !$omp parallel do reduction(+:x)
+ do i=1,100
+ x = x + 1
+ end do
+ !$omp end parallel do
+end subroutine
More information about the flang-commits
mailing list