[flang-commits] [flang] [ACC] Add support for force clause for loop collapse (PR #162534)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Wed Oct 8 12:15:52 PDT 2025
================
@@ -3190,22 +3190,47 @@ class FirConverter : public Fortran::lower::AbstractConverter {
std::get_if<Fortran::parser::OpenACCCombinedConstruct>(&acc.u);
Fortran::lower::pft::Evaluation *curEval = &getEval();
+ // Determine collapse depth/force and loopCount
+ bool collapseForce = false;
+ uint64_t collapseDepth = 1;
+ uint64_t loopCount = 1;
+ auto parseCollapse = [&](const Fortran::parser::AccClauseList &cl)
+ -> std::pair<bool, uint64_t> {
+ bool force = false;
+ uint64_t depth = 1;
+ for (const Fortran::parser::AccClause &clause : cl.v) {
+ if (const auto *collapseClause =
+ std::get_if<Fortran::parser::AccClause::Collapse>(&clause.u)) {
+ const Fortran::parser::AccCollapseArg &arg = collapseClause->v;
+ force = std::get<bool>(arg.t);
+ const auto &intExpr =
+ std::get<Fortran::parser::ScalarIntConstantExpr>(arg.t);
+ if (const auto *expr = Fortran::semantics::GetExpr(intExpr)) {
----------------
razvanlupusoru wrote:
Having collapse clause parsing in a single place would be ideal. We currently have `getLoopCountForCollapseAndTile` in OpenACC.cpp. Any chance to make something similar - like getLoopCountForCollapse - and then use it both here and in getLoopCountForCollapseAndTile.
https://github.com/llvm/llvm-project/pull/162534
More information about the flang-commits
mailing list