[flang-commits] [flang] [flang][OpenMP] Add lowering of subroutine calls in custom reduction combiners (PR #169808)
Jan Leyonberg via flang-commits
flang-commits at lists.llvm.org
Fri Nov 28 05:25:14 PST 2025
================
@@ -3621,15 +3635,32 @@ processReductionCombiner(lower::AbstractConverter &converter,
auto declareOp =
hlfir::DeclareOp::create(builder, loc, addr, name.ToString(), nullptr,
{}, nullptr, nullptr, 0, attributes);
+ if (name.ToString() == "omp_out")
+ ompOutVar = declareOp.getResult(0);
symTable.addVariableDefinition(*name.symbol, declareOp);
}
lower::StatementContext stmtCtx;
- mlir::Value result = fir::getBase(
- convertExprToValue(loc, converter, evalExpr, symTable, stmtCtx));
- if (auto refType = llvm::dyn_cast<fir::ReferenceType>(result.getType()))
- if (lhs.getType() == refType.getElementType())
- result = fir::LoadOp::create(builder, loc, result);
+ mlir::Value result = common::visit(
+ common::visitors{
+ [&](const evaluate::ProcedureRef &procRef) -> mlir::Value {
+ convertCallToHLFIR(loc, converter, procRef, std::nullopt,
+ symTable, stmtCtx);
+ auto outVal = fir::LoadOp::create(builder, loc, ompOutVar);
+ return outVal;
+ },
+ [&](const auto &expr) -> mlir::Value {
+ mlir::Value exprResult = fir::getBase(convertExprToValue(
+ loc, converter, evalExpr, symTable, stmtCtx));
+ // Optional load may be generated if we get a reference to the
+ // reduction type.
+ if (auto refType =
+ llvm::dyn_cast<fir::ReferenceType>(exprResult.getType()))
+ if (lhs.getType() == refType.getElementType())
+ exprResult = fir::LoadOp::create(builder, loc, exprResult);
----------------
jsjodin wrote:
They are two different cases, one is for the input to this region, the other is for the result after lowering the region itself. In both cases we may get a pointer instead of the value.
https://github.com/llvm/llvm-project/pull/169808
More information about the flang-commits
mailing list