https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103252
Bug ID: 103252
Summary: questionable codegen with kmovd
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jason at zx2c4 dot com
Target Milestone: ---
Created attachment 51798
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51798&action=edit
preprocessed source
gcc 11.2 with -march=native is generating avx512 code that seems less efficient
than the non avx512 case, for inet_aton_end in glibc 2.34.
Non-avx512 (-march=skylake):
mov ecx, ds:(__libc_tsd_CTYPE_B_tpoff - _GLOBAL_OFFSET_TABLE_)[ebx]
mov ecx, gs:[ecx]
Avx512:
kmovd k0, ds:(__libc_tsd_CTYPE_B_tpoff - _GLOBAL_OFFSET_TABLE_)[ebx]
kmovd edx, k0
kmovd k0, dword ptr gs:[edx]
kmovd edx, k0
Command line is:
thinkpad /var/tmp/portage/sys-libs/glibc-2.34-r2/work/glibc-2.34/resolv #
x86_64-pc-linux-gnu-gcc -m32 -march=native -pipe -O2 -Wl,-O1 -Wl,--as-needed
inet_addr.c -c -std=gnu11 -fgnu89-inline -march=native -pipe -O2 -Wall
-Wwrite-strings -Wundef -fmerge-all-constants -frounding-math
-fstack-protector-strong -fno-common -Wstrict-prototypes -Wold-style-definition
-fmath-errno -Wa,-mtune=i686 -ftls-model=initial-exec -U_FORTIFY_SOURCE
-I../include
-I/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv
-I/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl
-I../sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/i386/i686/nptl
-I../sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/x86/include
-I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/x86/nptl -I../sysdeps/i386/nptl
-I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
-I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu
-I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/i386
-I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu/multiarch
-I../sysdeps/i386/i686/fpu -I../sysdeps/i386/i686/multiarch
-I../sysdeps/i386/i686 -I../sysdeps/i386/fpu -I../sysdeps/x86/fpu
-I../sysdeps/i386 -I../sysdeps/x86/include -I../sysdeps/x86
-I../sysdeps/wordsize-32 -I../sysdeps/ieee754/float128
-I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96
-I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754
-I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include -isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed -isystem /usr/include
-D_LIBC_REENTRANT -include
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC
-DTOP_NAMESPACE=glibc -o
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv/inet_addr.o
-MD -MP -MF
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv/inet_addr.o.dt
-MT
/var/tmp/portage/sys-libs/glibc-2.34-r2/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv/inet_addr.o
And the preprocessed -E source is attached. This was noticed during
investigating https://www.sourceware.org/bugzilla/show_bug.cgi?id=28595 , which
seems likely to be a binutils or glibc bug instead. But nonetheless, the code
gen here seems surprising.