[flang-commits] [flang] [Flang][OpenMP] Support declare reduction without initializer (PR #196211)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Sun May 17 06:35:40 PDT 2026


================
@@ -4119,18 +4119,95 @@ static ReductionProcessor::GenCombinerCBTy processReductionCombiner(
   return genCombinerCB;
 }
 
-// Checks that the reduction type is either a trivial type or a derived type of
-// trivial types.
+/// Recursively initialize components of a derived type variable inline.
+/// For each component:
+///   - If it has an explicit default initializer, use that value.
+///   - If it is itself a derived type with default component initialization,
+///     recurse into its sub-components.
+///   - Otherwise, zero-initialize.
+/// This avoids calling _FortranAInitialize (which is not fully supported  on
+/// GPU)
----------------
tblah wrote:

This approach seems wasteful on CPU. Maybe the GPU case should be handled as a separate  path.

I don't know much about the current GPU pipeline but this must not be the first time that someone has had to work around this lack of availability. If some other inline implementation or rewrite exists then I strongly recommend re-using that instead of re-inventing the wheel.

@skatrak @agozillon how is this handled in other cases on the GPU? E.g. for normal Fortran assignments that aren't optimised into loops/stores etc.

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


More information about the flang-commits mailing list