[UBUNTU 20.04] GCC Miscompilation in vectorized code

Bug #1856682 reported by bugproxy
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu on IBM z Systems
In Progress
High
Skipper Bug Screeners
gcc
Fix Released
High
gcc-5 (Ubuntu)
Invalid
Undecided
Unassigned
Xenial
Invalid
Undecided
Unassigned
Bionic
New
Undecided
Unassigned
Disco
Invalid
Undecided
Unassigned
Eoan
Invalid
Undecided
Unassigned
Focal
Invalid
Undecided
Unassigned
gcc-6 (Ubuntu)
Invalid
Undecided
Unassigned
Xenial
Invalid
Undecided
Unassigned
Bionic
New
Undecided
Unassigned
Disco
Invalid
Undecided
Unassigned
Eoan
Invalid
Undecided
Unassigned
Focal
Invalid
Undecided
Unassigned
gcc-7 (Ubuntu)
New
Undecided
Unassigned
Xenial
Invalid
Undecided
Unassigned
Bionic
New
Undecided
Unassigned
Disco
Invalid
Undecided
Unassigned
Eoan
Invalid
Undecided
Unassigned
Focal
New
Undecided
Unassigned
gcc-8 (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Invalid
Undecided
Unassigned
Bionic
Fix Released
Undecided
Unassigned
Disco
Invalid
Undecided
Unassigned
Eoan
Invalid
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned
gcc-9 (Ubuntu)
Fix Released
High
Canonical Foundations Team
Xenial
Invalid
Undecided
Unassigned
Bionic
Invalid
Undecided
Unassigned
Disco
Invalid
Undecided
Unassigned
Eoan
Invalid
Undecided
Unassigned
Focal
Fix Released
High
Canonical Foundations Team

Bug Description

Miscompilation in autovectorized code.

---Steps to Reproduce---
 See GCC BZ: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92950

The following testcase abort when being compiled with -O3 -march=z13 on IBM Z:

struct a {
  int b;
  char c;
};
struct a d = {1, 16};
struct a *e = &d;

int f = 0;

int main() {
  struct a g = {0, 0 };
  f = 0;

  for (; f <= 1; f++) {
    g = d;
    *e = g;
  }

  if (d.c != 16)
    __builtin_abort();
}

The movv1qi pattern emits halfword load instructions instead of character
loads.

All GCC versions since GCC 5 are affected.
Patches for GCC 8, 9, and 10 have been committed to the gcc.gnu.org branches.

Userspace tool common name: gcc
The userspace tool has the following bit modes: 64
Userspace rpm: various Ubuntu gcc packages

Package need to updated within LP

Revision history for this message
In , Krebbel (krebbel) wrote :

The following testcase abort when being compiled with -O3 -march=z13 on IBM Z:

struct a {
  int b;
  char c;
};
struct a d = {1, 16};
struct a *e = &d;

int f = 0;

int main() {
  struct a g = {0, 0 };
  f = 0;

  for (; f <= 1; f++) {
    g = d;
    *e = g;
  }

  if (d.c != 16)
    __builtin_abort();
}

The movv1qi pattern emits halfword load instructions instead of character loads.

Revision history for this message
In , Krebbel (krebbel) wrote :

Author: krebbel
Date: Mon Dec 16 08:03:28 2019
New Revision: 279410

URL: https://gcc.gnu.org/viewcvs?rev=279410&root=gcc&view=rev
Log:
Fix PR92950: Wrong code emitted for movv1qi

The backend emits 16 bit memory loads for single element character
vector. As a result the character will not be right justified in the
GPR.

gcc/ChangeLog:

2019-12-16 Andreas Krebbel <email address hidden>

 PR target/92950
 * config/s390/vector.md ("mov<mode>" for V_8): Replace lh, lhy,
 and lhrl with llc.

gcc/testsuite/ChangeLog:

2019-12-16 Andreas Krebbel <email address hidden>

 PR target/92950
 * gcc.target/s390/vector/pr92950.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/s390/vector/pr92950.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/s390/vector.md
    trunk/gcc/testsuite/ChangeLog

Revision history for this message
In , Krebbel (krebbel) wrote :

Author: krebbel
Date: Tue Dec 17 08:37:26 2019
New Revision: 279453

URL: https://gcc.gnu.org/viewcvs?rev=279453&root=gcc&view=rev
Log:
Fix PR92950: Wrong code emitted for movv1qi

The backend emits 16 bit memory loads for single element character
vector. As a result the character will not be right justified in the
GPR.

gcc/ChangeLog:

2019-12-17 Andreas Krebbel <email address hidden>

 Backport from mainline
 2019-12-16 Andreas Krebbel <email address hidden>

 PR target/92950
 * config/s390/vector.md ("mov<mode>" for V_8): Replace lh, lhy,
 and lhrl with llc.

gcc/testsuite/ChangeLog:

2019-12-17 Andreas Krebbel <email address hidden>

 Backport from mainline
 2019-12-16 Andreas Krebbel <email address hidden>

 PR target/92950
 * gcc.target/s390/vector/pr92950.c: New test.

Added:
    branches/gcc-9-branch/gcc/testsuite/gcc.target/s390/vector/pr92950.c
Modified:
    branches/gcc-9-branch/gcc/ChangeLog
    branches/gcc-9-branch/gcc/config/s390/vector.md
    branches/gcc-9-branch/gcc/testsuite/ChangeLog

Revision history for this message
In , Krebbel (krebbel) wrote :

Author: krebbel
Date: Tue Dec 17 08:41:54 2019
New Revision: 279454

URL: https://gcc.gnu.org/viewcvs?rev=279454&root=gcc&view=rev
Log:
Fix PR92950: Wrong code emitted for movv1qi

The backend emits 16 bit memory loads for single element character
vector. As a result the character will not be right justified in the
GPR.

gcc/ChangeLog:

2019-12-17 Andreas Krebbel <email address hidden>

 Backport from mainline
 2019-12-16 Andreas Krebbel <email address hidden>

 PR target/92950
 * config/s390/vector.md ("mov<mode>" for V_8): Replace lh, lhy,
 and lhrl with llc.

gcc/testsuite/ChangeLog:

2019-12-17 Andreas Krebbel <email address hidden>

 Backport from mainline
 2019-12-16 Andreas Krebbel <email address hidden>

 PR target/92950
 * gcc.target/s390/vector/pr92950.c: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gcc.target/s390/vector/pr92950.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/config/s390/vector.md
    branches/gcc-8-branch/gcc/testsuite/ChangeLog

bugproxy (bugproxy)
tags: added: architecture-s39064 bugnameltc-182958 severity-high targetmilestone-inin2004
Changed in ubuntu:
assignee: nobody → Skipper Bug Screeners (skipper-screen-team)
affects: ubuntu → linux (Ubuntu)
Frank Heimes (fheimes)
affects: linux (Ubuntu) → gcc-defaults (Ubuntu)
Changed in ubuntu-z-systems:
importance: Undecided → High
Changed in gcc-defaults (Ubuntu):
importance: Undecided → High
Changed in ubuntu-z-systems:
assignee: nobody → Skipper Bug Screeners (skipper-screen-team)
Changed in gcc-defaults (Ubuntu):
assignee: Skipper Bug Screeners (skipper-screen-team) → Canonical Foundations Team (canonical-foundations)
Changed in ubuntu-z-systems:
status: New → Triaged
Revision history for this message
Matthias Klose (doko) wrote :

which releases need a fix?

affects: gcc-defaults (Ubuntu) → gcc-9 (Ubuntu)
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2019-12-17 06:42 EDT-------
(In reply to comment #7)
> which releases need a fix?

All releases on GCC 5 branch starting with 5.2
and all releases on 6, 7, 8, and 9 branches unfortunately.

Revision history for this message
Dimitri John Ledkov (xnox) wrote : Re: GCC Miscompilation in vectorized code

* Update to SVN 20200104 (r279880) from the gcc-9-branch.
      ...
      PR target/92950 (S390),

In focal, for gcc-9.

Changed in gcc-9 (Ubuntu):
status: New → Fix Released
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

gcc-5 affected in xenial and bionic.

gcc-6 affected in bionic only.

gcc-7 and gcc-8 affected, and currently have inflight SRU updates to v7.5 and v8.3 in bionic, thus are not going to be updated at the moment anywhere I don't think.

gcc-9 is fixed in focal.

Changed in gcc-6 (Ubuntu Eoan):
status: New → Invalid
Changed in gcc-6 (Ubuntu Focal):
status: New → Invalid
Changed in gcc-6 (Ubuntu Xenial):
status: New → Invalid
Changed in gcc-5 (Ubuntu Disco):
status: New → Invalid
Changed in gcc-5 (Ubuntu Eoan):
status: New → Invalid
Changed in gcc-5 (Ubuntu Focal):
status: New → Invalid
Changed in gcc-7 (Ubuntu Xenial):
status: New → Invalid
Changed in gcc-8 (Ubuntu Xenial):
status: New → Invalid
Changed in gcc-9 (Ubuntu Xenial):
status: New → Invalid
Changed in gcc-9 (Ubuntu Bionic):
status: New → Invalid
Changed in gcc:
importance: Unknown → High
status: Unknown → New
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2020-02-07 07:01 EDT-------
@CAN: any update on progress ? Many thanks in advance

summary: - GCC Miscompilation in vectorized code
+ [UBUNTU 20.04] GCC Miscompilation in vectorized code
Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Assuming fixed.

Revision history for this message
In , Krebbel (krebbel) wrote :

Fixed

Changed in gcc:
status: New → Fix Released
Revision history for this message
Frank Heimes (fheimes) wrote :

Moving all disco entries to Invalid, since disco already EOLed.

Changed in gcc-6 (Ubuntu Disco):
status: New → Invalid
Changed in gcc-7 (Ubuntu Disco):
status: New → Invalid
Changed in gcc-8 (Ubuntu Disco):
status: New → Invalid
Changed in gcc-9 (Ubuntu Disco):
status: New → Invalid
Revision history for this message
Frank Heimes (fheimes) wrote :

Changing the Eoan entries to Invalid, since Eoan reached it's EOL: https://lists.ubuntu.com/archives/ubuntu-announce/2020-July/000258.html

Changed in gcc-7 (Ubuntu Eoan):
status: New → Invalid
Changed in gcc-8 (Ubuntu Eoan):
status: New → Invalid
Changed in gcc-9 (Ubuntu Eoan):
status: New → Invalid
Changed in gcc-8 (Ubuntu):
status: New → Fix Released
Changed in gcc-8 (Ubuntu Focal):
status: New → Fix Released
Changed in gcc-8 (Ubuntu Bionic):
status: New → Fix Released
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: Triaged → In Progress
Revision history for this message
Frank Heimes (fheimes) wrote :

This is a long running ticket - since the missing (less relevant) ones will come over time and in combination with other updates.

Revision history for this message
Frank Heimes (fheimes) wrote :

Changing xenial entries to Incomplete, since the base support ended.

Changed in gcc-5 (Ubuntu Xenial):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.