[flang-commits] [flang] [Flang] [OpenMP]Support for multiple types in declare_reduction (PR #179442)

Jack Styles via flang-commits flang-commits at lists.llvm.org
Tue Feb 3 07:17:03 PST 2026


================
@@ -3884,31 +3884,32 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
   const auto &specifier =
       DEREF(parser::omp::GetFirstArgument<parser::OmpReductionSpecifier>(
           construct.v));
-  if (std::get<parser::OmpTypeNameList>(specifier.t).v.size() > 1)
-    TODO(converter.getCurrentLocation(),
-         "multiple types in declare reduction is not yet supported");
-
-  mlir::Type reductionType = getReductionType(converter, specifier);
+  const auto &typeNameList = std::get<parser::OmpTypeNameList>(specifier.t);
   List<Clause> clauses = makeClauses(construct.v.Clauses(), semaCtx);
   const clause::Combiner &combiner =
       appendCombiner(construct, clauses, semaCtx);
-
-  ReductionProcessor::GenCombinerCBTy genCombinerCB =
-      processReductionCombiner(converter, symTable, semaCtx, combiner);
-
-  ReductionProcessor::GenInitValueCBTy genInitValueCB;
-  ClauseProcessor cp(converter, semaCtx, clauses);
-  cp.processInitializer(symTable, genInitValueCB);
-
   const auto &identifier =
       std::get<parser::OmpReductionIdentifier>(specifier.t);
   const auto &designator = std::get<parser::ProcedureDesignator>(identifier.u);
   const auto &reductionName = std::get<parser::Name>(designator.u);
-  bool isByRef = ReductionProcessor::doReductionByRef(reductionType);
-  ReductionProcessor::createDeclareReductionHelper<
-      mlir::omp::DeclareReductionOp>(
-      converter, reductionName.ToString(), reductionType,
-      converter.getCurrentLocation(), isByRef, genCombinerCB, genInitValueCB);
+
+  for (const auto &typeSpec : typeNameList.v) {
+    mlir::Type reductionType = getReductionType(converter, specifier);
+
+    ReductionProcessor::GenCombinerCBTy genCombinerCB =
+        processReductionCombiner(converter, symTable, semaCtx, combiner);
+
+    ReductionProcessor::GenInitValueCBTy genInitValueCB;
+    ClauseProcessor cp(converter, semaCtx, clauses);
+    cp.processInitializer(symTable, genInitValueCB);
+
+    bool isByRef = ReductionProcessor::doReductionByRef(reductionType);
+
----------------
Stylie777 wrote:

nit: Unnecessary whitespace

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


More information about the flang-commits mailing list