From: Thomas Koenig Date: Sun, 21 Sep 2025 12:46:35 +0000 (+0200) Subject: Fix test case and add errors for when -fexternal-blas64 makse no sense. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f28eb8ab909712aaf6517c0c818e5b36de32383;p=thirdparty%2Fgcc.git Fix test case and add errors for when -fexternal-blas64 makse no sense. -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. --- diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index d62ee819997..a65f2d1cc34 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -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} diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index 35c1924a9c9..21839ef4a4f 100644 --- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -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) diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 1754d982153..a9e512ed135 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -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; diff --git a/gcc/testsuite/gfortran.dg/matmul_blas_3.f90 b/gcc/testsuite/gfortran.dg/matmul_blas_3.f90 index d496596b5da..bf02a38c458 100644 --- a/gcc/testsuite/gfortran.dg/matmul_blas_3.f90 +++ b/gcc/testsuite/gfortran.dg/matmul_blas_3.f90 @@ -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)