public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model
@ 2024-06-08 12:24 sjames at gcc dot gnu.org
  2024-06-08 12:30 ` [Bug tree-optimization/115395] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-08 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115395
           Summary: [15 regression] libarchive miscompiled with -O2
                    -march=znver2 -fno-vect-cost-model
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Created attachment 58382
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58382&action=edit
bad.c

libarchive fails several tests with -O3 -march=znver2 -fno-vect-cost-model. I
picked 'libarchive_test_read_format_rar_multivolume_seek_data' to reduce.

```
$ gcc-15 test.c -o /tmp/test -O2 -march=znver2 && /tmp/test ; echo $?
0

$ gcc-15 test.c -o /tmp/test -O2 -fno-vect-cost-model -march=znver2 &&
/tmp/test && echo $?
aborting on wrong offset=214
Aborted (core dumped)
134
```

--

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/15/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/15
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/15/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/15
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/15/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/15/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15
--disable-silent-rules --disable-dependency-tracking
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/15/python
--enable-languages=c,c++,fortran,rust --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--disable-libunwind-exceptions --enable-checking=yes,extra,rtl
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened
15.0.9999 p, commit 9a866462097fe24696c924a3874fd307c775e860'
--with-gcc-major-version-only --enable-libstdcxx-time --enable-lto
--disable-libstdcxx-pch --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all
--enable-libgomp --disable-libssp --disable-libada --disable-cet
--disable-systemtap --enable-valgrind-annotations --disable-vtable-verify
--disable-libvtv --with-zstd --with-isl --disable-isl-version-check
--enable-default-pie --enable-host-pie --enable-host-bind-now
--enable-default-ssp --disable-fixincludes --with-build-config='bootstrap-O3
bootstrap-lto'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.0 20240607 (experimental)
a3d68b5155018817dd7eef5abbaeadf3959b8e5e (Gentoo Hardened 15.0.9999 p, commit
9a866462097fe24696c924a3874fd307c775e860)

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
@ 2024-06-08 12:30 ` pinskia at gcc dot gnu.org
  2024-06-08 12:37 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-08 12:30 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |15.0
                 CC|                            |pinskia at gcc dot gnu.org
   Target Milestone|---                         |15.0
           Keywords|                            |wrong-code

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
  2024-06-08 12:30 ` [Bug tree-optimization/115395] " pinskia at gcc dot gnu.org
@ 2024-06-08 12:37 ` pinskia at gcc dot gnu.org
  2024-06-08 13:45 ` [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca sjames at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-08 12:37 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-06-08
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

Looks like it is doing the add twice:
```
  vect_offset_14.29_104 = _84 + vect__18.28_103;
  _106 = .REDUC_PLUS (vect_offset_14.29_104);
  _107 = offset_9 + _106;
```

Once before the reduction and once after.

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
  2024-06-08 12:30 ` [Bug tree-optimization/115395] " pinskia at gcc dot gnu.org
  2024-06-08 12:37 ` pinskia at gcc dot gnu.org
@ 2024-06-08 13:45 ` sjames at gcc dot gnu.org
  2024-06-08 16:11 ` sjames at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-08 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
            Summary|[15 regression] libarchive  |[15 regression] libarchive
                   |miscompiled with -O2        |miscompiled with -O2
                   |-march=znver2               |-march=znver2
                   |-fno-vect-cost-model        |-fno-vect-cost-model since
                   |                            |r15-1006-gd93353e6423eca

--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
r15-1006-gd93353e6423eca

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-06-08 13:45 ` [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca sjames at gcc dot gnu.org
@ 2024-06-08 16:11 ` sjames at gcc dot gnu.org
  2024-06-10  6:39 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-08 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
Tidied up a bit:
```
struct {
  long header_size;
  long start_offset;
  long end_offset;
} myrar_dbo[5] = {{0, 87, 6980}, {0, 7087, 13980}, {0, 14087, 0}};

int i;
long offset;

int main() {
  offset += myrar_dbo[0].start_offset;
  while (i < 2) {
    i++;
    offset += myrar_dbo[i].start_offset - myrar_dbo[i - 1].end_offset;
  }
  if (offset != 301)
    __builtin_abort();
}
```

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-06-08 16:11 ` sjames at gcc dot gnu.org
@ 2024-06-10  6:39 ` rguenth at gcc dot gnu.org
  2024-06-10  7:31 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-10  6:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-06-10  6:39 ` rguenth at gcc dot gnu.org
@ 2024-06-10  7:31 ` rguenth at gcc dot gnu.org
  2024-06-10  8:03 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-10  7:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
It needs epilogue vectorization to trigger and it's the path re-using the
vector accumulator from the earlier loop that goes wrong when the main
vector loop is skipped.

We apply the initial value adjustment to the scalar result but the
continuation fails to do this and the epilogue vector epilogue expects
the earlier code to have done it.

IIRC we force "optimization" of this to be disabled but obviously somehow
fail to do this for SLP.

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-06-10  7:31 ` rguenth at gcc dot gnu.org
@ 2024-06-10  8:03 ` rguenth at gcc dot gnu.org
  2024-06-10  9:39 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-10  8:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
In fact, the main loop ends up not using SLP but the epilogue one does and
we end up setting STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT which we do not
support for SLP.

The question is whether to add that support or simply fail (but this is
code generation).  It's probably easiest to transitionally implement
support and rip it out again later.

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-06-10  8:03 ` rguenth at gcc dot gnu.org
@ 2024-06-10  9:39 ` cvs-commit at gcc dot gnu.org
  2024-06-10  9:49 ` rguenth at gcc dot gnu.org
  2024-06-10 11:20 ` sjames at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-10  9:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:4ed9c5df7efeb98e190573cca42a4fd40666c45f

commit r15-1160-g4ed9c5df7efeb98e190573cca42a4fd40666c45f
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jun 10 10:12:52 2024 +0200

    tree-optimization/115395 - wrong-code with SLP reduction in epilog

    When we continue a non-SLP reduction from the main loop in the
    epilog with a SLP reduction we currently fail to handle an
    adjustment by the initial value because that's not a thing with SLP.
    As long as we have the possibility to mix SLP and non-SLP we have
    to handle it though.

            PR tree-optimization/115395
            * tree-vect-loop.cc (vect_create_epilog_for_reduction):
            Handle STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT also for SLP
            reductions of group_size one.

            * gcc.dg/vect/pr115395.c: New testcase.

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2024-06-10  9:39 ` cvs-commit at gcc dot gnu.org
@ 2024-06-10  9:49 ` rguenth at gcc dot gnu.org
  2024-06-10 11:20 ` sjames at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-10  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

* [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca
  2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2024-06-10  9:49 ` rguenth at gcc dot gnu.org
@ 2024-06-10 11:20 ` sjames at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-10 11:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Sam James <sjames at gcc dot gnu.org> ---
Thanks for the quick fix! We had another issue which bisected to the same, but
it was far harder to reduce so we decided to wait. Hopefully fixed by this too.

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

end of thread, other threads:[~2024-06-10 11:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-08 12:24 [Bug tree-optimization/115395] New: [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model sjames at gcc dot gnu.org
2024-06-08 12:30 ` [Bug tree-optimization/115395] " pinskia at gcc dot gnu.org
2024-06-08 12:37 ` pinskia at gcc dot gnu.org
2024-06-08 13:45 ` [Bug tree-optimization/115395] [15 regression] libarchive miscompiled with -O2 -march=znver2 -fno-vect-cost-model since r15-1006-gd93353e6423eca sjames at gcc dot gnu.org
2024-06-08 16:11 ` sjames at gcc dot gnu.org
2024-06-10  6:39 ` rguenth at gcc dot gnu.org
2024-06-10  7:31 ` rguenth at gcc dot gnu.org
2024-06-10  8:03 ` rguenth at gcc dot gnu.org
2024-06-10  9:39 ` cvs-commit at gcc dot gnu.org
2024-06-10  9:49 ` rguenth at gcc dot gnu.org
2024-06-10 11:20 ` sjames 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).