public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/115115] New: [12/13/14/15 Regression] highway-1.0.7 wrong _mm_cvttps_epi32() constant fold
@ 2024-05-15 21:38 slyfox at gcc dot gnu.org
  2024-05-15 21:45 ` [Bug target/115115] " slyfox at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: slyfox at gcc dot gnu.org @ 2024-05-15 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115115
           Summary: [12/13/14/15 Regression] highway-1.0.7 wrong
                    _mm_cvttps_epi32() constant fold
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Initially I observed the testsuite failure on highway-1.0.7 library as on
r15-523-g1a05332bbac98a.

I reduced it down to the following:

```c
// $ cat bug.c
#include <emmintrin.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

__attribute__((noipa))
static void dump_m128i(const char * prefix, const __m128i * v) {
  uint32_t p[4];
  memcpy(p, v, 16);
  fprintf(stderr, "%s:", prefix);
  for (size_t i = 0; i < 4; ++i) {
    fprintf(stderr, " %#08x", p[i]);
  }
  fprintf(stderr, "\n");
}

__attribute__((noipa))
static void assert_m128i(const __m128i * v) {
  uint32_t p[4];
  memcpy(p, v, 16);
  uint32_t q[4] = {
      0x80000000,
      0x80000000,
      0x80000000,
      0x80000000,
  };
  if (memcmp(p, q, 16) != 0) __builtin_abort();
}

__attribute__((noipa))
static void TestAllF2IPromoteTo() {
  const __m128i iv = _mm_set_epi32(0x4f000000, 0x4f000000, 0x4f000000,
0x4f000000);
  const __m128  fv = _mm_castsi128_ps(iv);
  const __m128i riv = _mm_cvttps_epi32(fv);

  dump_m128i("riv", &riv);
  assert_m128i(&riv);
}

int main() {
    TestAllF2IPromoteTo();
}
```

Triggering:

$ gcc-15 bug.c -o a -O0 && ./a
riv: 0x80000000 0x80000000 0x80000000 0x80000000
# ok?

$ gcc-15 bug.c -o a -O1 && ./a
riv: 0x7fffffff 0x7fffffff 0x7fffffff 0x7fffffff
Aborted (core dumped)
# bad?

I think highway expect the former. At least gcc-8/9/10/11 pass the test.
gcc-12/13/14/15 all fail it.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-15.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-15.0.0/libexec/gcc/x86_64-unknown-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../source/configure --prefix=/<<NIX>>/gcc-15.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.1-dev/include
--with-mpfr-lib=/<<NIX>>/mpfr-4.2.1/lib --with-mpc=/<<NIX>>/libmpc-1.3.1
--with-native-system-header-dir=/<<NIX>>/glibc-2.39-52-dev/include
--with-build-sysroot=/
--with-gxx-include-dir=/<<NIX>>/gcc-15.0.0/include/c++/15.0.0/
--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 15.0.0 99999999 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-06-20  9:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15 21:38 [Bug target/115115] New: [12/13/14/15 Regression] highway-1.0.7 wrong _mm_cvttps_epi32() constant fold slyfox at gcc dot gnu.org
2024-05-15 21:45 ` [Bug target/115115] " slyfox at gcc dot gnu.org
2024-05-15 21:49 ` pinskia at gcc dot gnu.org
2024-05-15 22:00 ` slyfox at gcc dot gnu.org
2024-05-16  0:36 ` liuhongt at gcc dot gnu.org
2024-05-16  7:12 ` rguenth at gcc dot gnu.org
2024-05-16  9:08 ` slyfox at gcc dot gnu.org
2024-05-16  9:14 ` pinskia at gcc dot gnu.org
2024-05-16 21:57 ` slyfox at gcc dot gnu.org
2024-05-17  8:27 ` jan.wassenberg at gmail dot com
2024-05-17  9:22 ` jan.wassenberg at gmail dot com
2024-05-17 18:10 ` jan.wassenberg at gmail dot com
2024-05-20 13:56 ` slyfox at gcc dot gnu.org
2024-05-20 15:48 ` jan.wassenberg at gmail dot com
2024-06-05  4:09 ` cvs-commit at gcc dot gnu.org
2024-06-05  9:12 ` slyfox at gcc dot gnu.org
2024-06-20  9:15 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).