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

            Bug ID: 118537
           Summary: [14 Regression; 20241102 -> 20241128] wrong
                    initialization of member variable on Graviton [related
                    to tree-slp-vectorize]
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: j...@jak-linux.org
  Target Milestone: ---

I did not have time for a full debug and minimal reproducer yet (I had a
visitor all day after the first 1-2 hours debugging it this morning :D), but
maybe this already is useful to someone:

APT in Debian recently received a bug report that it was failing to do https
downloads on Graviton instances were failing. The struct RequestState has a
member defined as

enum {Chunked,Stream,Closes} Encoding = Closes;

Running on Graviton, the constructor - inlined - resulted in the member
initializing with 0 (Chunked) instead of 2 (Closes). Valgrind on Graviton and
other arm64 platforms did not see the same issue.

Debugging this on Ubuntu revealed a regression in a gcc-14 update, particular
in one of the commits (14.2.0-8ubuntu1 was good, 14.2.0-9ubuntu1 with the
following changes is bad):

  * Update to git 20241128 from the gcc-14 branch.
    - Fix PR target/117564 (PA), PR target/117525 (PA), PR target/117408 (ARM),
      PR target/117443 (PA), PR target/116999 (AArch64),
      PR target/117045 (AArch64), PR target/116629 (AArch64),
      PR target/116371 (AArch64), PR target/117304 (x86),
      PR target/116371 (AArch64), PR tree-optimization/117398,
      PR tree-optimization/117287, PR middle-end/117354, PR target/117296,
      PR ada/117328, PR ada/113868, PR ada/113036, PR c++/117158,
      PR c++/101463, PR c++/116634, PR fortran/115700, PR fortran/115700,
      PR fortran/115070, PR fortran/115348, PR libstdc++/117520,
      PR libstdc++/117406, PR target/117562 (x86), PR target/117744 (AVR),
      PR other/116603, PR testsuite/109360, PR target/117357 (x86),
      PR target/117659 (AVR), PR middle-end/116997, PR target/117418 (x86),
      PR target/117500 (AVR), PR ada/115917, PR analyzer/115724,
      PR analyzer/111475, PR fortran/117763, PR fortran/84869,
      PR fortran/116388, PR fortran/109345, PR fortran/104819,
      PR fortran/115700, PR fortran/115700, PR fortran/115070,
      PR fortran/115348, PR fortran/79685, PR fortran/84868, PR fortran/100273,
      PR fortran/116530, PR fortran/108889, PR modula2/116378,
      PR modula2/116181, PR modula2/115823, PR modula2/116048,
      PR modula2/115957, PR modula2/115804, PR modula2/115540,
      PR modula2/115536, PR modula2/114529, PR modula2/115057,
      PR modula2/115003, PR preprocessor/117118, PR modula2/115276.

In the attached diff of the instructions - which have been amended with
__asm__("isb sy"); around the call of the constructor to find it we see a
notable difference:

+movi   v31.4s, #0x0
[...]
+stur   q31, [x2, #232]
+stur   q31, [x2, #248]

These may be related (do q31 and v31 overlap?), certainly no vector
instructions were used before which led me to specify
optimize("no-tree-slp-vectorize") on the function the constructor is being
called from; which worked around the issue.

For sake of completeness, A workaround has been shipped in APT 2.9.23 that
simply changes the enum order such that 0 is the correct default value:
https://salsa.debian.org/apt-team/apt/-/commit/98ddccc

Reply via email to