Bug 111051 - [14 Regression] highway-1.0.6 fails to build as gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avxintrin.h:1238:1: error: inlining failed in call to 'always_inline' '__m256d _mm256_setzero_pd()': target specific option mismatch
Summary: [14 Regression] highway-1.0.6 fails to build as gcc-14.0.0/lib/gcc/x86_64-unk...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 14.0
: P3 blocker
Target Milestone: 14.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2023-08-17 20:44 UTC by Sergei Trofimovich
Modified: 2023-09-08 10:52 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-08-17 20:44:39 UTC
Observed build failure on today's gcc from r14-3296-gdc48d1d1d44587 against highway-1.0.6 ( https://github.com/google/highway ).

I have not managed to extract nice example ot of it yet, but maybe it's obvious to you?

The (somewhat big) reproducer is:

$ git clone https://github.com/google/highway
$ cd highway
$ mkdir b
$ cd b
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make
...

LANG=C /nix/store/vmrxs83fhqs6d3gsyg97hh0lbfzhk9jl-gcc-wrapper-14.0.0/bin/g++ -DHWY_STATIC_DEFINE -DTOOLCHAIN_MISS_ASM_HWCAP_H -I/home/slyfox/dev/git/highway -isystem /home/slyfox/dev/git/highway/b/googletest-src/googletest/include -isystem /home/slyfox/dev/git/highway/b/googletest-src/googletest -O3 -DNDEBUG -fPIE -fvisibility=hidden -fvisibility-inlines-hidden -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\" -fmerge-all-constants -Wall -Wextra -Wconversion -Wsign-conversion -Wvla -Wnon-virtual-dtor -fmath-errno -fno-exceptions -DHWY_IS_TEST=1 -MD -MT CMakeFiles/math_test.dir/hwy/contrib/math/math_test.cc.o -MF CMakeFiles/math_test.dir/hwy/contrib/math/math_test.cc.o.d -o CMakeFiles/math_test.dir/hwy/contrib/math/math_test.cc.o -c /home/slyfox/dev/git/highway/hwy/contrib/math/math_test.cc
In file included from /nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/immintrin.h:71,
                 from /home/slyfox/dev/git/highway/hwy/ops/x86_256-inl.h:36,
                 from /home/slyfox/dev/git/highway/hwy/highway.h:407,
                 from /home/slyfox/dev/git/highway/hwy/contrib/math/math_test.cc:25,
                 from /home/slyfox/dev/git/highway/hwy/foreach_target.h:94,
                 from /home/slyfox/dev/git/highway/hwy/contrib/math/math_test.cc:24:
/nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avx512vldqintrin.h: In function '__m256 _mm256_mask_xor_ps(__m256, __mmask8, __m256, __m256)':
/nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avx512vldqintrin.h:1154:1: note: the ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
 1154 | _mm256_mask_xor_ps (__m256 __W, __mmask8 __U, __m256 __A, __m256 __B)
      | ^~~~~~~~~~~~~~~~~~
/home/slyfox/dev/git/highway/hwy/contrib/math/math_test.cc:439:1: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
  439 | }  // namespace hwy
      | ^
In file included from /nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/immintrin.h:43:
/nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avxintrin.h: In function '__m256d _mm256_cvtepi64_pd(__m256i)':
/nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avxintrin.h:1238:1: error: inlining failed in call to 'always_inline' '__m256d _mm256_setzero_pd()': target specific option mismatch
 1238 | _mm256_setzero_pd (void)
      | ^~~~~~~~~~~~~~~~~
/nix/store/9j5pznccwi0vzmj91w8yr2kiwdm37c5p-gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avx512vldqintrin.h:912:10: note: called from here
  912 |   return (__m256d) __builtin_ia32_cvtqq2pd256_mask ((__v4di) __A,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  913 |                                                     (__v4df)
      |                                                     ~~~~~~~~
  914 |                                                     _mm256_setzero_pd (),
      |                                                     ~~~~~~~~~~~~~~~~~~~~~
  915 |                                                     (__mmask8) -1);
      |                                                     ~~~~~~~~~~~~~~

I have a suspiction it's related to AVX10 changes, like r14-3268-g0b20e0f17b47a8  which remove `#pragma GCC target("avx512vl,avx512dq")`. Probably not that one specifically though.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../source/configure --prefix=/<<NIX>>/gcc-14.0.0 --with-gmp-include=/<<NIX>>/gmp-6.3.0-dev/include --with-gmp-lib=/<<NIX>>/gmp-6.3.0/lib --with-mpfr-include=/<<NIX>>/mpfr-4.2.0-12-dev/include --with-mpfr-lib=/<<NIX>>/mpfr-4.2.0-12/lib --with-mpc=/<<NIX>>/libmpc-1.3.1 --with-native-system-header-dir=/<<NIX>>/glibc-2.38-dev/include --with-build-sysroot=/ --program-prefix= --enable-lto --disable-libstdcxx-pch --without-included-gettext --with-system-zlib --enable-checking=release --enable-static --enable-languages=c,c++ --disable-multilib --enable-plugin --disable-libcc1 --with-isl=/<<NIX>>/isl-0.20 --disable-bootstrap --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 99999999 (experimental) (GCC)
Comment 1 Sergei Trofimovich 2023-08-17 21:26:01 UTC
Found this difference, looks reasonable?

// $ cat a.cc
#include <immintrin.h>

#pragma GCC target("avx512vl,avx512dq")

void bug(__m256i i) {
   volatile auto v1 = _mm256_cvtepi64_pd(i);
}

Difference:

$ g++-13 -c a.cc
# ok

$ g++-14 -c a.cc
In file included from /<<NIX>>/gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/immintrin.h:71,
                 from a.cc:1:
/<<NIX>>/gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avx512vldqintrin.h: In function '__m256d _mm256_cvtepi64_pd(__m256i)':
/<<NIX>>/gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avx512vldqintrin.h:910:1: note: the ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
  910 | _mm256_cvtepi64_pd (__m256i __A)
      | ^~~~~~~~~~~~~~~~~~
a.cc:7:1: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
    7 | }
      | ^
In file included from /<<NIX>>/gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/immintrin.h:43:
/<<NIX>>/gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avxintrin.h:1238:1: error: inlining failed in call to 'always_inline' '__m256d _mm256_setzero_pd()': target specific option mismatch
 1238 | _mm256_setzero_pd (void)
      | ^~~~~~~~~~~~~~~~~
/<<NIX>>/gcc-14.0.0/lib/gcc/x86_64-unknown-linux-gnu/14.0.0/include/avx512vldqintrin.h:912:10: note: called from here
  912 |   return (__m256d) __builtin_ia32_cvtqq2pd256_mask ((__v4di) __A,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  913 |                                                     (__v4df)
      |                                                     ~~~~~~~~
  914 |                                                     _mm256_setzero_pd (),
      |                                                     ~~~~~~~~~~~~~~~~~~~~~
  915 |                                                     (__mmask8) -1);
      |                                                     ~~~~~~~~~~~~~~
Comment 2 Haochen Jiang 2023-08-18 02:54:20 UTC
It is caused by when including immintrin.h, since the pragma is removed, there will be no AVX support, which makes _mm256_setzero_pd invisible.

Adding a AVX2 pragma instead of removing it should solve the problem.

I am working a patch on that.
Comment 3 Haochen Jiang 2023-08-18 06:02:05 UTC
See patch:

https://gcc.gnu.org/pipermail/gcc-patches/2023-August/627829.html
Comment 4 GCC Commits 2023-08-18 07:46:51 UTC
The master branch has been updated by Haochen Jiang <jianghc@gcc.gnu.org>:

https://gcc.gnu.org/g:68f7cb6cf9e8b9f2254855507f3b479552adda5f

commit r14-3318-g68f7cb6cf9e8b9f2254855507f3b479552adda5f
Author: Haochen Jiang <haochen.jiang@intel.com>
Date:   Fri Aug 18 11:05:16 2023 +0800

    i386: Add AVX2 pragma wrapper for AVX512DQVL intrins
    
            PR target/111051
    
    gcc/ChangeLog:
    
            * config/i386/avx512vldqintrin.h: Push AVX2 when AVX2 is
            disabled.
    
    gcc/testsuite/ChangeLog:
    
            PR target/111051
            * gcc.target/i386/pr111051-1.c: New test.
Comment 5 Sergei Trofimovich 2023-08-18 07:55:26 UTC
The change fixed highway-1.0.6 build for me. Thank you!
Comment 6 Mathieu Malaterre 2023-09-08 09:08:43 UTC
looks like this one should be marked fixed.
Comment 7 Sergei Trofimovich 2023-09-08 10:52:45 UTC
Sounds reasonable. Closing as FIXED.