diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -997,7 +997,7 @@ llvm::SmallVector reductionOperands, privateOperands, firstprivateOperands; - llvm::SmallVector privatizations; + llvm::SmallVector privatizations, reductionRecipes; // Async, wait and self clause have optional values but can be present with // no value as well. When there is no value, the op has an attribute to @@ -1151,8 +1151,11 @@ &clause.u)) { genObjectList(firstprivateClause->v, converter, semanticsContext, stmtCtx, firstprivateOperands); - } else if (std::get_if(&clause.u)) { - TODO(clauseLocation, "compute construct reduction clause lowering"); + } else if (const auto *reductionClause = + std::get_if( + &clause.u)) { + genReductions(reductionClause->v, converter, semanticsContext, stmtCtx, + reductionOperands, reductionRecipes); } } @@ -1194,6 +1197,9 @@ if (!privatizations.empty()) computeOp.setPrivatizationsAttr( mlir::ArrayAttr::get(builder.getContext(), privatizations)); + if (!reductionRecipes.empty()) + computeOp.setReductionRecipesAttr( + mlir::ArrayAttr::get(builder.getContext(), reductionRecipes)); } auto insPt = builder.saveInsertionPoint(); diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -558,7 +558,7 @@ return failure(); if (failed(checkSymOperandList( *this, getReductionRecipes(), getReductionOperands(), "reduction", - "reductions"))) + "reductions", false))) return failure(); return checkDataOperands(*this, getDataClauseOperands()); } @@ -586,7 +586,7 @@ return failure(); if (failed(checkSymOperandList( *this, getReductionRecipes(), getReductionOperands(), "reduction", - "reductions"))) + "reductions", false))) return failure(); return checkDataOperands(*this, getDataClauseOperands()); }