[flang-commits] [flang] [flang][acc] Implement cache directive lowering (PR #174897)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Fri Jan 9 09:34:58 PST 2026
================
@@ -3506,7 +3506,14 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genFIR(const Fortran::parser::OpenACCConstruct &acc) {
mlir::OpBuilder::InsertPoint insertPt = builder->saveInsertionPoint();
- localSymbols.pushScope();
+
+ // Cache constructs should not push/pop a scope because they need to update
+ // the symbol map for subsequent statements in the same loop body.
----------------
razvanlupusoru wrote:
I really like the second example because it looks like a valid use case; however, with the current version of OpenACC specification, its effect is ambiguous. Specifically: "When the cache directive appears at the top of (inside of) a loop, it suggests array elements or subarrays would benefit by being fetched into the highest level of the cache for the body of the loop.". Therefore, the scope of the caching is for the loop duration which would only be only the loop in which it is used.
I agree it would be nice to see if we can somehow support the pattern above but it likely will require revisions to OpenACC spec.
https://github.com/llvm/llvm-project/pull/174897
More information about the flang-commits
mailing list