[llvm-branch-commits] [flang] [flang][OpenMP] lower simple array reductions (PR #84958)
Tom Eccles via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Mar 15 09:44:45 PDT 2024
================
@@ -390,15 +559,35 @@ void ReductionProcessor::addReductionDecl(
// initial pass to collect all recuction vars so we can figure out if this
// should happen byref
+ fir::FirOpBuilder &builder = converter.getFirOpBuilder();
for (const Fortran::parser::OmpObject &ompObject : objectList.v) {
if (const auto *name{
Fortran::parser::Unwrap<Fortran::parser::Name>(ompObject)}) {
if (const Fortran::semantics::Symbol * symbol{name->symbol}) {
if (reductionSymbols)
reductionSymbols->push_back(symbol);
mlir::Value symVal = converter.getSymbolAddress(*symbol);
- if (auto declOp = symVal.getDefiningOp<hlfir::DeclareOp>())
+ auto redType = mlir::cast<fir::ReferenceType>(symVal.getType());
----------------
tblah wrote:
The existing upstream code already does this, I was mostly moving code around here. See line 434 in the old version of the code.
This even predates the by-ref reduction changes. See https://github.com/llvm/llvm-project/blob/f18d78b477c76bc09dc580cdaedd55e121f5ebf5/flang/lib/Lower/OpenMP/ReductionProcessor.cpp#L347
For example, if you look at the llvm code we generate by-val reductions (which should be identical after my changes), it loaded the reduction variables unconditionally, so this must be some kind of pointer.
https://github.com/llvm/llvm-project/pull/84958
More information about the llvm-branch-commits
mailing list