simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.36k stars 247 forks source link

Incomplete detection of gcc bug in simde/x86/avx512/abs.h #1117

Closed thomas-schlichter closed 10 months ago

thomas-schlichter commented 10 months ago

In the functions simde_mm512_abs_pd() and simde_mm512_mask_abs_pd() a workaround for a gcc bug is applied for gcc versions >= 7.0.0 and < 8.3.0 . But the bug was also fixed for gcc versions >= 7.4.0 and < 8.0.0 .

Therefore I propose to modify the checks accordingly:

SIMDE_FUNCTION_ATTRIBUTES
simde__m512d
simde_mm512_abs_pd(simde__m512d v2) {
- #if defined(SIMDE_X86_AVX512F_NATIVE) && (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(8,3,0))
+ #if defined(SIMDE_X86_AVX512F_NATIVE) && (!defined(HEDLEY_GCC_VERSION) || (HEDLEY_GCC_VERSION_CHECK(7,4,0) && !HEDLEY_GCC_VERSION_CHECK(8,0,0)) || HEDLEY_GCC_VERSION_CHECK(8,3,0))
    return _mm512_abs_pd(v2);
  #elif defined(SIMDE_X86_AVX512F_NATIVE) && (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(7,0,0))
    /* gcc bug: https://gcc.gnu.org/legacy-ml/gcc-patches/2018-01/msg01962.html */
    return _mm512_abs_pd(_mm512_castpd_ps(v2));
  #else
SIMDE_FUNCTION_ATTRIBUTES
simde__m512d
simde_mm512_mask_abs_pd(simde__m512d src, simde__mmask8 k, simde__m512d v2) {
- #if defined(SIMDE_X86_AVX512F_NATIVE) && (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(8,3,0))
+ #if defined(SIMDE_X86_AVX512F_NATIVE) && (!defined(HEDLEY_GCC_VERSION) || (HEDLEY_GCC_VERSION_CHECK(7,4,0) && !HEDLEY_GCC_VERSION_CHECK(8,0,0)) || HEDLEY_GCC_VERSION_CHECK(8,3,0))
    return _mm512_mask_abs_pd(src, k, v2);
  #elif defined(SIMDE_X86_AVX512F_NATIVE) && (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(7,0,0))
    /* gcc bug: https://gcc.gnu.org/legacy-ml/gcc-patches/2018-01/msg01962.html */
    return _mm512_mask_abs_pd(src, k, _mm512_castpd_ps(v2));
  #else
mr-c commented 10 months ago

@thomas-schlichter Do you have a GCC bug number?

thomas-schlichter commented 10 months ago

Yes, it is this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87467