[flang-commits] [flang] [flang][OpenMP] Support user-defined declare reduction with derived types (PR #184897)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Mar 9 10:38:46 PDT 2026


================
@@ -1,14 +1,23 @@
-! RUN: not %flang_fc1 -emit-mlir -fopenmp %s -o - 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-mlir -fopenmp %s -o - | FileCheck %s
 
 program test
   type t
      integer :: x
   end type t
-  ! CHECK: not yet implemented: Reduction of some types is not supported
   !$omp declare reduction(+:t: omp_out%x = omp_out%x + omp_in%x) initializer(omp_priv = t(0))
   type(t) :: a
   a = t(0)
   !$omp parallel reduction(+:a)
   a%x = a%x + 1
   !$omp end parallel
 end program test
+
+! CHECK: omp.declare_reduction @add_reduction_byref_rec__QFTt : !fir.ref<!fir.type<_QFTt{x:i32}>>
+! CHECK-SAME: attributes {byref_element_type = !fir.type<_QFTt{x:i32}>}
+! CHECK: alloc {
+! CHECK:   omp.yield
+! CHECK: } init {
+! CHECK:   omp.yield
+! CHECK: } combiner {
+! CHECK:   omp.yield
+! CHECK: }
----------------
tblah wrote:

Please check for the lines actually implementing the reduction too so we can see that everything gets wired up correctly. This will also ensure there is a test for the new path without a store at the end of the combiner region.

https://github.com/llvm/llvm-project/pull/184897


More information about the flang-commits mailing list