Skip to content

Commit 72e6be5

Browse files
committed
[flang] Skip processing reductions for unstructured do concurrent loops
Fixes #149563 When emitting unstructured `do concurrent` loops, reduction processing should be skipped since we are not emitting `fir.do_concurrent` loop in the first place.
1 parent eb63f55 commit 72e6be5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21152115
}
21162116
}
21172117

2118+
if (!doConcurrentLoopOp)
2119+
return;
2120+
21182121
llvm::SmallVector<bool> reduceVarByRef;
21192122
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
21202123
llvm::SmallVector<mlir::Attribute> nestReduceAttrs;

flang/test/Lower/do_loop_unstructured.f90

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,22 @@ subroutine nested_structured_in_unstructured()
232232
! CHECK: cf.br ^[[HEADER]]
233233
! CHECK: ^[[EXIT]]:
234234
! CHECK: return
235+
236+
subroutine unstructured_do_concurrent
237+
logical :: success
238+
do concurrent (i=1:10) local(success)
239+
error stop "fail"
240+
enddo
241+
end
242+
! CHECK-LABEL: func.func @_QPunstructured_do_concurrent
243+
! CHECK: %[[ITER_VAR:.*]] = fir.alloca i32
244+
245+
! CHECK: ^[[HEADER]]:
246+
! CHECK: %{{.*}} = fir.load %[[ITER_VAR]] : !fir.ref<i32>
247+
! CHECK: cf.cond_br %{{.*}}, ^[[BODY:.*]], ^[[EXIT:.*]]
248+
249+
! CHECK: ^[[BODY]]:
250+
! CHECK-NEXT: %{{.*}} = fir.alloca !fir.logical<4> {bindc_name = "success", {{.*}}}
251+
252+
! CHECK: ^[[EXIT]]:
253+
! CHECK-NEXT: return

0 commit comments

Comments
 (0)