[Patch] OpenMP/Fortran: Handle simdlen's 'scaled' modifier; for > / >= checks, enforce const check [PR127723]

Tobias Burnus tburnus@baylibre.com
Sun Oct 11 11:55:59 GMT 2026


Add Fortran support for the 'scaled' modifier to simdlen:

   !$omp (declare) simd … simdlen( [ scaled(type [, divisor] ) : ] length )

where 'type' is a numeric type and 'divisor' and 'length' are >= 1 and
known at compile time.


When doing this, I noticed that some of the >= 1 and >= 0 checks in
openmp.cc only checked for this for constants (with a warning) while
for non-constants, those just were accepted. I changed the function
to also have a hard error and requiring constant. Hence:

For, e.g., 'num_threads(n)' - n might be (still) a variable but if
it is constant, there is the >= 0 check. - This one is *unchanged* and
just shows a warning - but I think an error would also be fine and,
actually, make more sense.

However, for the following clauses, *now* a hard error is printed:

* SAFELEN  (OpenMP) [fixed a test case]
* SIMDLEN's length expression (OpenMP)

* SIMDLEN >= SIMDLEN (new check, unrelated to that change, but for completeness)

* SIMDLEN's divisor expression (OpenMP; new modifier)

* PRIORITY  (OpenMP, no idea why it needs to be constant, but it is;
              fixed some testcases)

* SIZES  (OpenMP, simplified check; BTW: OpenMP 6 permits it to be non-const)

* TILE   (OpenACC, simplified check + changed warning to an error)


Additionally, I fixed a module handling error for 'simd' in 'declare variant'.


Any comments before I push this patch?

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simdlen-scaled-fortran.diff
Type: text/x-patch
Size: 53780 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20261011/e2611e94/attachment-0001.bin>


More information about the Gcc-patches mailing list