[llvm-branch-commits] [flang] [flang] Skip processing reductions for unstructured `do concurrent` loops (PR #150188)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 23 01:36:10 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Kareem Ergawy (ergawy)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/150188.diff
2 Files Affected:
- (modified) flang/lib/Lower/Bridge.cpp (+3)
- (modified) flang/test/Lower/do_loop_unstructured.f90 (+19)
``````````diff
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 13420f365919d..a6362b1e2f5ca 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -2115,6 +2115,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
}
+ if (!doConcurrentLoopOp)
+ return;
+
llvm::SmallVector<bool> reduceVarByRef;
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
llvm::SmallVector<mlir::Attribute> nestReduceAttrs;
diff --git a/flang/test/Lower/do_loop_unstructured.f90 b/flang/test/Lower/do_loop_unstructured.f90
index d8890b2d0926e..176ea5ccee129 100644
--- a/flang/test/Lower/do_loop_unstructured.f90
+++ b/flang/test/Lower/do_loop_unstructured.f90
@@ -232,3 +232,22 @@ subroutine nested_structured_in_unstructured()
! CHECK: cf.br ^[[HEADER]]
! CHECK: ^[[EXIT]]:
! CHECK: return
+
+subroutine unstructured_do_concurrent
+ logical :: success
+ do concurrent (i=1:10) local(success)
+ error stop "fail"
+ enddo
+end
+! CHECK-LABEL: func.func @_QPunstructured_do_concurrent
+! CHECK: %[[ITER_VAR:.*]] = fir.alloca i32
+
+! CHECK: ^[[HEADER]]:
+! CHECK: %{{.*}} = fir.load %[[ITER_VAR]] : !fir.ref<i32>
+! CHECK: cf.cond_br %{{.*}}, ^[[BODY:.*]], ^[[EXIT:.*]]
+
+! CHECK: ^[[BODY]]:
+! CHECK-NEXT: %{{.*}} = fir.alloca !fir.logical<4> {bindc_name = "success", {{.*}}}
+
+! CHECK: ^[[EXIT]]:
+! CHECK-NEXT: return
``````````
</details>
https://github.com/llvm/llvm-project/pull/150188
More information about the llvm-branch-commits
mailing list