Skip to content

Commit cace715

Browse files
[Flang][OpenMP] Process reduction only once for parallel do (#70844)
1 parent f671584 commit cace715

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

flang/lib/Lower/OpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,8 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
23122312
cp.processProcBind(procBindKindAttr);
23132313
cp.processDefault();
23142314
cp.processAllocate(allocatorOperands, allocateOperands);
2315-
cp.processReduction(currentLocation, reductionVars, reductionDeclSymbols);
2315+
if (!outerCombined)
2316+
cp.processReduction(currentLocation, reductionVars, reductionDeclSymbols);
23162317

23172318
return genOpWithBody<mlir::omp::ParallelOp>(
23182319
converter, eval, currentLocation, outerCombined, &clauseList,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! Check that for parallel do, reduction is only processed for the loop
2+
3+
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
4+
! RUN: flang-new -fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
5+
6+
! CHECK: omp.parallel {
7+
! CHECK: omp.wsloop reduction(@add_reduction_i_32
8+
subroutine sb
9+
integer :: x
10+
x = 0
11+
!$omp parallel do reduction(+:x)
12+
do i=1,100
13+
x = x + 1
14+
end do
15+
!$omp end parallel do
16+
end subroutine

0 commit comments

Comments
 (0)