[flang-commits] [flang] [flang][openacc] Relax semantic check on cache directive (PR #184887)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Mar 5 13:11:50 PST 2026
https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/184887
>From 0cfb6e4508434107a35a39c32ce1e535b182323a Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 5 Mar 2026 13:05:13 -0800
Subject: [PATCH] [flang][openacc] Relax semantic check on cache directive
---
flang/lib/Semantics/check-acc-structure.cpp | 6 ------
flang/test/Lower/OpenACC/acc-cache.f90 | 16 ++++++++++++++++
.../Semantics/OpenACC/acc-cache-validity.f90 | 6 ++----
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index 0a41484399b56..732531b1bdfcc 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -688,13 +688,7 @@ void AccStructureChecker::Enter(const parser::OpenACCCacheConstruct &x) {
if (const auto *triplet =
std::get_if<parser::SubscriptTriplet>(
&subscript.u)) {
- const auto &lower{std::get<0>(triplet->t)};
- const auto &upper{std::get<1>(triplet->t)};
const auto &stride{std::get<2>(triplet->t)};
- if (!lower && !upper) {
- context_.Say(designator.source,
- "The CACHE directive requires at least one of the bounds in the array section subscript triplet to be specified"_err_en_US);
- }
if (stride) {
if (auto strideVal{GetIntValue(*stride)}) {
if (*strideVal != 1) {
diff --git a/flang/test/Lower/OpenACC/acc-cache.f90 b/flang/test/Lower/OpenACC/acc-cache.f90
index 36874d3c21cdb..d2da6ef62d7e8 100644
--- a/flang/test/Lower/OpenACC/acc-cache.f90
+++ b/flang/test/Lower/OpenACC/acc-cache.f90
@@ -767,3 +767,19 @@ subroutine test_cache_temp_in_designator(data, a)
! CHECK: hlfir.designate %[[DECL]]#0
! CHECK: acc.yield
end subroutine
+
+
+subroutine full_array_cache()
+ integer :: k, j , kd, jd,y, x
+ real(8) :: tile(0:8,0:8)
+
+ !$acc parallel loop gang collapse(2)
+ do k = 1, kd
+ do j = 1, jd
+ !$acc cache(tile(:,:))
+ end do
+ end do
+end subroutine
+
+! CHECK-LABEL: func.func @_QPfull_array_cache()
+! CHECK: acc.cache var(%{{.*}}) bounds(%{{.*}})
diff --git a/flang/test/Semantics/OpenACC/acc-cache-validity.f90 b/flang/test/Semantics/OpenACC/acc-cache-validity.f90
index de66043de1ec8..aaffd4ec30a95 100644
--- a/flang/test/Semantics/OpenACC/acc-cache-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-cache-validity.f90
@@ -38,11 +38,9 @@ program openacc_cache_validity
!ERROR: Only array element or subarray are allowed in CACHE directive
!$acc cache(/i/)
- !ERROR: The CACHE directive requires at least one of the bounds in the array section subscript triplet to be specified
- !$acc cache(a(:))
+ !$acc cache(a(:)) ! ok
- !ERROR: The CACHE directive requires at least one of the bounds in the array section subscript triplet to be specified
- !$acc cache(aa(:,:))
+ !$acc cache(aa(:,:)) ! ok
!ERROR: The CACHE directive does not support strided array sections
!$acc cache(a(1:10:2))
More information about the flang-commits
mailing list