Skip to content

Commit 5ada328

Browse files
authored
[flang][OpenMP] ensure we hit the TODO for intrinsic array reduction (#90593)
Before this patch we crashed lowering intrinsic array reductions. I think this lost during a rebase. I've added a test to make sure it doesn't break again. Also fixed the TODO message to be more accurate.
1 parent d97f25b commit 5ada328

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

flang/lib/Lower/OpenMP/ReductionProcessor.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -811,14 +811,11 @@ void ReductionProcessor::addDeclareReduction(
811811
*reductionIntrinsic)) {
812812
ReductionProcessor::ReductionIdentifier redId =
813813
ReductionProcessor::getReductionType(*reductionIntrinsic);
814-
for (const Object &object : objectList) {
815-
const Fortran::semantics::Symbol *symbol = object.id();
816-
mlir::Value symVal = converter.getSymbolAddress(*symbol);
817-
if (auto declOp = symVal.getDefiningOp<hlfir::DeclareOp>())
818-
symVal = declOp.getBase();
814+
for (mlir::Value symVal : reductionVars) {
819815
auto redType = mlir::cast<fir::ReferenceType>(symVal.getType());
820816
if (!redType.getEleTy().isIntOrIndexOrFloat())
821-
TODO(currentLocation, "User Defined Reduction on non-trivial type");
817+
TODO(currentLocation,
818+
"Reduction of some types is not supported for intrinsics");
822819
decl = createDeclareReduction(
823820
firOpBuilder,
824821
getReductionName(getRealName(*reductionIntrinsic).ToString(),
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
! RUN: %not_todo_cmd bbc -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
! RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
3+
4+
! CHECK: not yet implemented: Reduction of some types is not supported for intrinsics
5+
subroutine max_array_reduction(l, r)
6+
integer :: l(:), r(:)
7+
8+
!$omp parallel reduction(max:l)
9+
l = max(l, r)
10+
!$omp end parallel
11+
end subroutine

0 commit comments

Comments
 (0)