https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116878

            Bug ID: 116878
           Summary: [15 regression] libcall emitted unnecessarily for
                    __popcountdi2
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Hit this with an `allmodconfig` of linux-6.6.52 (aware of the controversy there
in general).

When building the following w/ `-O2 -fsanitize-coverage=trace-cmp`, it looks
lik we get an inefficient(?) libcall to _popcountdi2:
```
int s_jquota_fmt;
void seq_printf();
void ext4_init_fs_contextext4_show_options() {
  char *fmtname = "";
  switch (s_jquota_fmt) {
  case 1:
    fmtname = "vfsold";
    break;
  case 2:
    fmtname = "vfsv0";
    break;
  case 4:
    fmtname = "vfsv1";
  }
  seq_printf(fmtname);
}
```

See https://godbolt.org/z/TjTMW345h. With 14, we don't emit the libcall, and
Clang doesn't either (but needs -fno-jump-tables as well as the kernel
originally built with).

--

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/15/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/15
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/15/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/15
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/15/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/15/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15
--disable-silent-rules --disable-dependency-tracking
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/15/python
--enable-objc-gc --enable-languages=c,c++,d,go,objc,obj-c++,fortran,ada,m2,rust
--enable-obsolete --enable-secureplt --disable-werror --with-system-zlib
--enable-nls --without-included-gettext --disable-libunwind-exceptions
--enable-checking=yes,extra,rtl --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo Hardened 15.0.9999 p, commit
3e1c7a2699f90793d9bf7107cb0b5943ba7c76c1' --with-gcc-major-version-only
--enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point
--enable-targets=all --enable-libgomp --disable-libssp --enable-libada
--disable-cet --disable-systemtap --enable-valgrind-annotations
--disable-vtable-verify --disable-libvtv --with-zstd --with-isl
--disable-isl-version-check --enable-default-pie --enable-host-pie
--enable-host-bind-now --enable-default-ssp --disable-fixincludes
--with-build-config='bootstrap-O3 bootstrap-lto'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240927 (experimental)
0ff49a5c1d39382c57d614a29510559068947376 (Gentoo Hardened 15.0.9999 p, commit
3e1c7a2699f90793d9bf7107cb0b5943ba7c76c1)

Reply via email to