Fixes #88935 Toggling reduction by-ref broke when multiple reduction clauses were used. Decisions made for the by-ref status for later clauses could then invalidate decisions for earlier clauses. For example, ``` reduction(+:scalar,scalar2) reduction(+:array) ``` The first clause would choose by value reduction and generate by-value reduction regions, but then after this the second clause would force by-ref to support the array argument. But by the time the second clause is processed, the first clause has already had the wrong kind of reduction regions generated. This is solved by toggling whether a variable should be reduced by reference per variable. In the above example, this allows only `array` to be reduced by ref.
17 lines
481 B
Fortran
17 lines
481 B
Fortran
! Check that for parallel do, reduction is only processed for the loop
|
|
|
|
! RUN: bbc -fopenmp --force-byref-reduction -emit-hlfir %s -o - | FileCheck %s
|
|
! RUN: flang-new -fc1 -fopenmp -mmlir --force-byref-reduction -emit-hlfir %s -o - | FileCheck %s
|
|
|
|
! CHECK: omp.parallel {
|
|
! CHECK: omp.wsloop reduction(byref @add_reduction_byref_i32
|
|
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
|