[PATCH v4] x86: Set minimum x86-64 level marker [BZ #27318]
Florian Weimer
fweimer@redhat.com
Fri Mar 5 19:43:10 GMT 2021
* H. J. Lu:
> diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac
> index f94088f377..866dd984df 100644
> --- a/sysdeps/x86/configure.ac
> +++ b/sysdeps/x86/configure.ac
> @@ -101,11 +101,79 @@ libc_cv_include_x86_isa_level=no
> if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S); then
> count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
> if test "$count" = 1; then
> - libc_cv_include_x86_isa_level=yes
> + cat > conftest.c <<EOF
> +extern long double fmodl(long double x, long double y);
> +extern long double x, y;
> +long double
> +foo (void)
> +{
> + return fmodl (x, y);
> +}
> +EOF
> + ISA_LEVEL_CPPFLAGS=
> + if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -Os -ffast-math -S -o - conftest.c) | grep -q " sahf"; then
> + ISA_LEVEL_CPPFLAGS=-DHAS_LAHF_SAHF
> + fi
> + cat > conftest.c <<EOF
> +extern int x;
> +int
> +bar ()
> +{
> + return __builtin_bswap32 (x);
> +}
> +EOF
> + if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -O2 -S -o - conftest.c) | grep -q " movbe"; then
> + ISA_LEVEL_CPPFLAGS="$ISA_LEVEL_CPPFLAGS -DHAS_MOVBE"
> + fi
Please check -fverbose-asm output, I expect it to be less brittle. Like
when new tunings result in GCC not selecting the relevant instructions.
> +DEFAULT_ISA_LEVEL=(ISA_BASELINE | ISA_V2 | ISA_V3 | ISA_V4)
I don't think it's necessary to set this as a part of a configure check.
Perhaps define macros for SAHF and MOVBE, and check them in
sysdeps/x86/isa-level.c?
But I think there's another issue: If someone builds with an option like
mno-lzcnt, it will poke a hole into the ISA level, in the sense that V2
and V4 are support, but not V3. I think this is wrong, it should always
be an increasing progression.
Thanks,
Florian
More information about the Libc-alpha
mailing list