]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix test case and add errors for when -fexternal-blas64 makse no sense.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 21 Sep 2025 12:46:35 +0000 (14:46 +0200)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 21 Sep 2025 12:48:29 +0000 (14:48 +0200)
-fexternal-blas64 requires front-end optimization to be turned on.
This patch issues a hard error if this is not the case, and also issues
an error on not-64 bit systems, where specifying it would make no sense,
and lead to errors.  Finally, this makes sure that the test is only performed
on 64-bit systems.

I tried creating test cases for the hard errors for the wrong option
combinations, but didn't succeed; see the thread on the gcc mailing
list on that topic.  These can always be added afterwards.

gcc/fortran/ChangeLog:

PR fortran/121161
* invoke.texi: Mention that -ffrontend-optimize is required
for -fexternal-blas64.
* options.cc (gfc_post_options): Fatal error if -fexternal-blas64
is specified without -ffrontend-optimize.
* trans-types.cc (gfc_init_kinds): Fatal error if -fexternal-blas64
is specified on a system which does not have 64-bit ptrdiff_t.

gcc/testsuite/ChangeLog:

PR fortran/121161
* gfortran.dg/matmul_blas_3.f90: Add effective target lp64.

gcc/fortran/invoke.texi
gcc/fortran/options.cc
gcc/fortran/trans-types.cc
gcc/testsuite/gfortran.dg/matmul_blas_3.f90

index d62ee819997fbcf0ed652c8b58d2a69db0326293..a65f2d1cc34f181c510b19c6fe3617fbe946e445 100644 (file)
@@ -2027,7 +2027,8 @@ limit (see @option{-fblas-matmul-limit}).  This may be profitable if an
 optimized vendor BLAS library is available.  The BLAS library has
 to be specified at link time.  This option specifies a BLAS library
 with integer arguments of @code{KIND=8} (64 bits). It cannot be used
-together with @option{-fexternal-blas}.
+together with @option{-fexternal-blas}, and requires a 64-bit system.
+This option also requires @option{-ffrontend-optimize}.
 
 @opindex fblas-matmul-limit
 @item -fblas-matmul-limit=@var{n}
index 35c1924a9c9b2031497f59069a5870dda9644cec..21839ef4a4f99e2f4f206b59066037e14b324243 100644 (file)
@@ -515,6 +515,9 @@ gfc_post_options (const char **pfilename)
   if (flag_frontend_optimize == -1)
     flag_frontend_optimize = optimize && !optimize_debug;
 
+  if (flag_external_blas64 && !flag_frontend_optimize)
+    gfc_fatal_error ("-ffrontend-optimize required for -fexternal-blas64");
+
   /* Same for front end loop interchange.  */
 
   if (flag_frontend_loop_interchange == -1)
index 1754d9821532b288ea3406966702f0ac5ae444bb..a9e512ed135d82cc1a80fa720c3c6f0e02dd3047 100644 (file)
@@ -800,6 +800,9 @@ gfc_init_kinds (void)
 
   gfc_index_integer_kind = get_int_kind_from_name (PTRDIFF_TYPE);
 
+  if (flag_external_blas64 && gfc_index_integer_kind != gfc_integer_8_kind)
+    gfc_fatal_error ("-fexternal-blas64 requires a 64-bit system");
+
   /* Pick a kind the same size as the C "int" type.  */
   gfc_c_int_kind = INT_TYPE_SIZE / 8;
 
index d496596b5dabd739c5d84720d50d5c7758f536e5..bf02a38c458cd9422851fc5298ac430d6007b391 100644 (file)
@@ -1,5 +1,6 @@
 ! { dg-do compile }
 ! { dg-options "-ffrontend-optimize -fexternal-blas64 -fdump-tree-original" }
+! { dg-require-effective-target lp64 }
 ! PR 121161 - option for 64-bit BLAS for MATMUL.
 ! Check this by making sure there is no KIND=4 integer.
 subroutine foo(a,b,c,n)