public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/95493] New: [10 Regression] test for vector members apparently reordered with assignment to vector members
@ 2020-06-03  7:49 kretz at kde dot org
  2020-06-03  8:15 ` [Bug tree-optimization/95493] [10/11 Regression] test for vector members apparently reordered with assignment to vector members since r10-7523-gb90061c6ec090c6b marxin at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: kretz at kde dot org @ 2020-06-03  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95493
           Summary: [10 Regression] test for vector members apparently
                    reordered with assignment to vector members
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kretz at kde dot org
  Target Milestone: ---

Test case (https://godbolt.org/z/egnkd7), compile with `-O2 -std=c++17`:

#include <cstdio>

struct verify
{
  const bool m_failed = false;

  [[gnu::noinline]] void print_hex(const void* x, int n) const
  {
    const auto* bytes = static_cast<const unsigned char*>(x);
    for (int i = 0; i < n; ++i)
      __builtin_fprintf(stderr, (i && i % 4 == 0) ? "'%02x" : "%02x",
bytes[i]);
    __builtin_fprintf(stderr, "\n");
  }

  template <typename... Ts>
  verify(bool ok, const Ts&... extra_info) : m_failed(!ok)
  {
    if (m_failed)
      (print_hex(&extra_info, sizeof(extra_info)), ...);
  }

  ~verify()
  {
    if (m_failed)
      __builtin_abort();
  }
};

using K [[gnu::vector_size(16)]] = int;

int
main()
{
  int count = 1;
  asm("" : "+m"(count));
  verify(count == 1, 0, "", 0);

  {
    struct SW
    {
      K d;
    };
    struct
    {
      SW d;
    } xx;
    SW& x = xx.d;
    x = SW(); // [0, 0, 0, 0]
    for (int i = 3; i >= 2; --i)
      {
        x.d[i] = -1; // [0, 0, 0, -1] ...
        int a = [](K y) {
          for (int j = 0; j < 4; ++j)
            if (y[j] != 0)
              return j;
          return -1;
        }(x.d);
        verify(a == i, 0, 0, 0, 0, i, x);
      }
  }
}


The relevant code here is:
```
using K [[gnu::vector_size(16)]] = int;
K x = K(); // [0, 0, 0, 0]
int i = 3;
x[i] = -1; // [0, 0, 0, -1]
int j;
for (j = 0; j < 4; ++j)
  if (x[j] != 0)
     break;
if (i != j) abort();
```

In a larger testcase I could see the assignment `x[i] = -1` getting reordered
with the "count zero" function in the disassembled test case.

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

end of thread, other threads:[~2020-06-23 13:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  7:49 [Bug tree-optimization/95493] New: [10 Regression] test for vector members apparently reordered with assignment to vector members kretz at kde dot org
2020-06-03  8:15 ` [Bug tree-optimization/95493] [10/11 Regression] test for vector members apparently reordered with assignment to vector members since r10-7523-gb90061c6ec090c6b marxin at gcc dot gnu.org
2020-06-03  8:20 ` [Bug middle-end/95493] " pinskia at gcc dot gnu.org
2020-06-03  9:51 ` [Bug rtl-optimization/95493] " rguenth at gcc dot gnu.org
2020-06-03 10:00 ` rguenth at gcc dot gnu.org
2020-06-03 11:15 ` rguenth at gcc dot gnu.org
2020-06-05  6:35 ` cvs-commit at gcc dot gnu.org
2020-06-05  6:36 ` [Bug rtl-optimization/95493] [10 " rguenth at gcc dot gnu.org
2020-06-16 11:57 ` rguenth at gcc dot gnu.org
2020-06-16 12:58 ` redi at gcc dot gnu.org
2020-06-16 22:15 ` cvs-commit at gcc dot gnu.org
2020-06-19 12:08 ` kretz at kde dot org
2020-06-19 12:29 ` rguenth at gcc dot gnu.org
2020-06-23 13:31 ` cvs-commit at gcc dot gnu.org
2020-06-23 13:31 ` 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).