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

* [Bug c++/98949] gcc-9.3 aarch64 -ftree-vectorize generates wrong code
  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 ` rguenth at gcc dot gnu.org
  2021-02-03  9:46 ` [Bug tree-optimization/98949] " cyb70289 at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-03  7:53 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
There are several open vectorizer regressions on older branches, some harder to
fix and thus fixes not backported.

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

* [Bug tree-optimization/98949] gcc-9.3 aarch64 -ftree-vectorize generates wrong code
  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 ` cyb70289 at gmail dot com
  2021-02-03 10:12 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cyb70289 at gmail dot com @ 2021-02-03  9:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Yibo Cai <cyb70289 at gmail dot com> ---
Thanks for quick response.

Ubuntu 20.04 installs gcc-9.3. It suffers from this bug. Looks no good.

$ g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

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

* [Bug tree-optimization/98949] gcc-9.3 aarch64 -ftree-vectorize generates wrong code
  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
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-02-03 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master with g:74166aabeb7f22990476b1169bba031b8323ee92, so likely a
dup of PR97236.

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

* [Bug tree-optimization/98949] gcc-9.3 aarch64 -ftree-vectorize generates wrong code
  2021-02-03  4:23 [Bug c++/98949] New: gcc-9.3 aarch64 -ftree-vectorize generates wrong code cyb70289 at gmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2021-02-05 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

ktkachov at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktkachov at gcc dot gnu.org

--- Comment #4 from ktkachov at gcc dot gnu.org ---
I can confirm that the commit
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1ab88985631dd2c5a5e3b5c0dce47cf8b6ed2f82
from PR97236 fixes the abort here.

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

* [Bug tree-optimization/98949] gcc-9.3 aarch64 -ftree-vectorize generates wrong code
  2021-02-03  4:23 [Bug c++/98949] New: gcc-9.3 aarch64 -ftree-vectorize generates wrong code cyb70289 at gmail dot com
                   ` (3 preceding siblings ...)
  2021-02-05 10:25 ` ktkachov at gcc dot gnu.org
@ 2021-02-05 15:44 ` ktkachov at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2021-02-05 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

ktkachov at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from ktkachov at gcc dot gnu.org ---
Dup. The patch fixing PR 97236 has been backported to the GCC 9 branch for GCC
9.4

*** This bug has been marked as a duplicate of bug 97236 ***

^ 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).