Tobias Burnus wrote:
Now committed as r17-4947-gfbcafeec06a661
such that simdlen( scaled(arithmetic-type [, divisor]): length)
now is now accepted (but fails then with a middle-end sorry).
I had hoped that I found a single location that always triggers
the sorry. Well, the spot I found didn't trigger when a target
hook as NULL. Thus, we will have to live with two locations:
one for C/C++ and one for Fortran.
The fix-up has been committed as r17-5029-g26e33a3c47ab54.
(Fortran support still to come, it's nearly ready.)
(Technically, 'simd' is only a hint, i.e. ignoring instead of a
sorry would work, but I think for now, the sorry makes sense
until the first actual middle-end support landed.)
Tobias Burnus wrote:
Tamar + Robbin: This was added to OpenMP 6.1 […]
for aarch64 / RISC-V as they have many vector modes.
Please take care of the middle-end part + target hooks, including
mangling,
once it landed
Looking forward to that part :-)
Also missing:
* Fortran
* When used with 'declare variant', I found a bug (C++-only): PR127734.
* It seems as if something should be done for the __simd__ attribute as
well (cf. far below).
[The last item (+ Fortran attributes): in x86-64, this attribute is used
to enable GLIBC's vector math functions via
math-vector.h/math-vecto-fortranr.h.]
PS: For type being equal, I currently check whether the type tree
is identical (pointer comparison); that should work for any normal code,
but with typeof or some 'typedef' one might end up having trees which
differ, e.g. in the qualifier. I am not sure that's a real issue or not.
Thoughts about this?
Tobias
commit 26e33a3c47ab54612f77dbfbd9827d729e8cfa41
Author: Tobias Burnus <[email protected]>
Date: Fri Oct 9 17:57:21 2026 +0200
OpenMP: Move 'sorry, unimplemented' for simdlen's 'scaled' modifier [PR127723]
This is a fixup to commit r17-4947-gfbcafeec06a661.
It turned out that the sorry message did not show up on system without
targetm.simd_clone.compute_vecsize_and_simdlen; hence, move the check to the
FE - for C/C++ to c_omp_declare_simd_clauses_to_numbers - such that it always
triggers. (Fortran, 'scaled' modifier support still has to be added.)
Note: It would be also fine not to sorry on those, but instead of finding
an effective target for this, moving the sorry was simpler. Note additionally
that 'simd' is effectively just a hint - such that silently ignoring 'scaled'
would also work, but the current solution seems to make more sense until there
is some actual support implemented on the vectorizer side.
The commit also fixes a not-fully working last-minute line-number change in
simdlen-scaled-4.c, which caused it to fail also when the hook was present.
PR middle-end/127723
gcc/c-family/ChangeLog:
* c-omp.cc (c_omp_declare_simd_clauses_to_numbers): Add sorry
diagnostic for simdlen with scaled modifer, moved from
omp-simd-clone.cc to ensure it is always active.
gcc/ChangeLog:
* omp-simd-clone.cc (simd_clone_clauses_extract): Remove sorry
diagnostic for simdlen with scaled modifier, moved to
c-family/c-omp.cc to ensure it is always active not only when
a target hook exists.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 6.1 Impl. Status): Link to Bugzilla
for the pending 'scaled' modifer to the 'simdlen' clause.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/simdlen-scaled-1.c: Update dg-message sorry
handling.
* c-c++-common/gomp/simdlen-scaled-4.c: Ditto.
* g++.dg/gomp/simdlen-scaled-1.C: Ditto.
* g++.dg/gomp/simdlen-scaled-2.C: Ditto.
diff --git a/gcc/c-family/c-omp.cc b/gcc/c-family/c-omp.cc
index 006e54d1e3d..e8580ae73e2 100644
--- a/gcc/c-family/c-omp.cc
+++ b/gcc/c-family/c-omp.cc
@@ -3155,6 +3155,10 @@ c_omp_declare_simd_clauses_to_numbers (tree parms, tree clauses)
for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
{
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SIMDLEN
+ && OMP_CLAUSE_SIMDLEN_TYPE (c))
+ sorry_at (OMP_CLAUSE_LOCATION (c),
+ "%<simdlen%> clause with %<scaled%> modifier");
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SIMDLEN
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE_INBRANCH
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE_NOTINBRANCH)
diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index 6ff3e583a12..1d670d4f11f 100644
--- a/gcc/omp-simd-clone.cc
+++ b/gcc/omp-simd-clone.cc
@@ -346,10 +346,6 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses,
case OMP_CLAUSE_SIMDLEN:
clone_info->simdlen
= TREE_INT_CST_LOW (OMP_CLAUSE_SIMDLEN_EXPR (t));
- if (OMP_CLAUSE_SIMDLEN_TYPE (t))
- sorry_at (DECL_SOURCE_LOCATION (node->decl),
- "%<scaled%> modifier specified in %<simdlen%> clause on "
- "%<declare simd%> directive for %qD", node->decl);
break;
case OMP_CLAUSE_LINEAR:
{
diff --git a/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-1.c b/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-1.c
index 32632af23f6..993ece73e0f 100644
--- a/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-1.c
@@ -5,18 +5,15 @@
#pragma omp declare simd simdlen(scaled(int, 1): 1)
void g1(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'g1'" "" { target c } .-1 }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g1\\(int\\)'" "" { target c++ } .-2 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
#pragma omp declare simd simdlen(scaled(float, 2): 2)
void g2(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'g2'" "" { target c } .-1 }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g2\\(int\\)'" "" { target c++ } .-2 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
#pragma omp declare simd simdlen(scaled(_Complex double): 4)
void g3(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'g3'" "" { target c } .-1 }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g3\\(int\\)'" "" { target c++ } .-2 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
/* { dg-final { scan-tree-dump "__attribute__\\(\\(omp declare simd \\(simdlen\\(scaled\\(int,1\\):1\\)\\)\\)\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "__attribute__\\(\\(omp declare simd \\(simdlen\\(scaled\\(float,2\\):2\\)\\)\\)\\)" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-4.c b/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-4.c
index 01f00922d80..574643235e8 100644
--- a/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-4.c
+++ b/gcc/testsuite/c-c++-common/gomp/simdlen-scaled-4.c
@@ -31,8 +31,10 @@ void f() {
}
// Once implemented remove ...
-// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } 19 }
-// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } 23 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } 10 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } 11 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } 16 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } 20 }
// ... and the following XFAIL should work ... (it fails because the clause is removed)
// { dg-final { scan-tree-dump-times "fvarInt2 \\(1\\);" 1 "gimple" { xfail *-*-* } } }
diff --git a/gcc/testsuite/g++.dg/gomp/simdlen-scaled-1.C b/gcc/testsuite/g++.dg/gomp/simdlen-scaled-1.C
index 9d826fa7cd8..704269f54e2 100644
--- a/gcc/testsuite/g++.dg/gomp/simdlen-scaled-1.C
+++ b/gcc/testsuite/g++.dg/gomp/simdlen-scaled-1.C
@@ -6,17 +6,17 @@
template<typename T, int d, long l>
[[omp::decl(declare simd,simdlen(scaled(T, d): l))]]
void g1(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g1\\(int\\) \\\[with T = int; int d = 1; long int l = 1\\\]'" "" { target *-*-* } .-1 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
template<typename T, int d, long l>
[[omp::decl(declare simd,simdlen(scaled(T, d + l): sizeof (T)))]]
void g2(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g2\\(int\\) \\\[with T = float; int d = 2; long int l = 0\\\]'" "" { target *-*-* } .-1 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
template<typename T, int d, long l>
[[omp::decl(declare simd,simdlen(scaled(T): l/d))]]
void g3(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g3\\(int\\) \\\[with T = __complex__ double; int d = 2; long int l = 8\\\]'" "" { target *-*-* } .-1 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
void f() {
g1<int, 1, 1>(1);
diff --git a/gcc/testsuite/g++.dg/gomp/simdlen-scaled-2.C b/gcc/testsuite/g++.dg/gomp/simdlen-scaled-2.C
index a180402f6b8..729a13b4e85 100644
--- a/gcc/testsuite/g++.dg/gomp/simdlen-scaled-2.C
+++ b/gcc/testsuite/g++.dg/gomp/simdlen-scaled-2.C
@@ -7,17 +7,17 @@
template<typename T, int d, long l>
[[omp::decl(declare simd,simdlen(scaled(T, d): l))]]
void g1(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g1\\(int\\) \\\[with T = int; int d = 1; long int l = 1\\\]'" "" { target *-*-* } .-1 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
template<typename T, int d, long l>
[[omp::decl(declare simd,simdlen(scaled(typeof (a), d + l): sizeof (T)))]]
void g2(T a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g2\\(T\\) \\\[with T = float; int d = 2; long int l = 0\\\]'" "" { target *-*-* } .-1 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
template<typename T, int d, long l>
[[omp::decl(declare simd,simdlen(scaled(T): l/d))]]
void g3(int a) { }
-// { dg-message "sorry, unimplemented: 'scaled' modifier specified in 'simdlen' clause on 'declare simd' directive for 'void g3\\(int\\) \\\[with T = __complex__ double; int d = 2; long int l = 8\\\]'" "" { target *-*-* } .-1 }
+// { dg-message "sorry, unimplemented: 'simdlen' clause with 'scaled' modifier" "" { target *-*-* } .-2 }
void f() {
g1<int, 1, 1>(1);
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 36fbbb3e3ef..f3f95df0c8b 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -693,6 +693,7 @@ Technical Report (TR) 15 is the second preview for OpenMP 6.1.
@item @code{grid} and @code{tile} modifier to the @code{size} clause @tab N @tab
@item New @code{flatten} loop-transforming directive @tab N @tab
@item @code{scaled} modifier to @code{simdlen} clause @tab N @tab
+ (@uref{https://gcc.gnu.org/PR127723,PR127723})
@item Lifted restriction on the first chunk size for the @code{schedule} clause
with @code{simd} modifier @tab N @tab
@item Change to the used chunk-size with the @code{schedule} clause and no