public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98949] New: gcc-9.3 aarch64 -ftree-vectorize generates wrong code
@ 2021-02-03  4:23 cyb70289 at gmail dot com
  2021-02-03  7:53 ` [Bug c++/98949] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: cyb70289 at gmail dot com @ 2021-02-03  4:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98949
           Summary: gcc-9.3 aarch64 -ftree-vectorize generates wrong code
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cyb70289 at gmail dot com
  Target Milestone: ---

Assertion fired in below test code when compiled with g++-9.3 aarch64 -O3.
Disable tree-vectorize fixes the issue.
g++-7, g++-10 don't have this problem.

$ uname -m
aarch64

$ g++-9 --version
g++-9 (Ubuntu 9.3.0-11ubuntu0~18.04.1) 9.3.0

$ g++-9 -O3 -march=armv8-a test.cc && ./a.out
a.out: test.cc:27: int main(): Assertion `bitmap[7] != 0' failed.
Aborted (core dumped)

$ g++-9 -O3 -fno-tree-vectorize -march=armv8-a test.cc && ./a.out
[assertion not fired]


test.cc
=======

#include <cassert>
#include <cstdint>

int main(void) {
  uint64_t a[64], b[64];
  for (int i = 0; i < 64; ++i) {
    a[i] = 1;
    b[i] = 2;
  }
  a[63] = b[63];  // only last element is the same

  uint8_t bitmap[8];  // holds 64 bits, bit_i = 1 if (a[i] == b[i]) else 0, i =
0 ~ 63
  int index = 0;  // index to a[], b[]
  for (int byte = 0; byte < 8; ++byte) {
    uint8_t out_results[8]; // holds 8 comparison results temporarily
    for (int bit = 0; bit < 8; ++bit) {
      out_results[bit] = a[index] == b[index];
      ++index;
    }
    bitmap[byte] = (out_results[0] | out_results[1] << 1 | out_results[2] << 2
|
                    out_results[3] << 3 | out_results[4] << 4 | out_results[5]
<< 5 |
                    out_results[6] << 6 | out_results[7] << 7);
  }

  // last bitmap should be non-zero, fired on gcc-9.3 aarch64 -O3
  assert(bitmap[7] != 0);
  return 0;
}

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

end of thread, other threads:[~2021-02-05 15:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03  4:23 [Bug c++/98949] New: gcc-9.3 aarch64 -ftree-vectorize generates wrong code cyb70289 at gmail dot com
2021-02-03  7:53 ` [Bug c++/98949] " rguenth at gcc dot gnu.org
2021-02-03  9:46 ` [Bug tree-optimization/98949] " cyb70289 at gmail dot com
2021-02-03 10:12 ` marxin at gcc dot gnu.org
2021-02-05 10:25 ` ktkachov at gcc dot gnu.org
2021-02-05 15:44 ` ktkachov 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).