public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13
@ 2023-04-13  6:22 mitskevichmn at gmail dot com
  2023-04-13  6:26 ` [Bug c/109493] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mitskevichmn at gmail dot com @ 2023-04-13  6:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109493
           Summary: Broken O2 optimization on s390x in GCC 13
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mitskevichmn at gmail dot com
  Target Milestone: ---

Created attachment 54847
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54847&action=edit
Preprocessed source

We found a problem in release version of a test (part of bee2 library test
suite) on Fedora Rawhide (39) official docker image.

Test fails with -O2 optimization on the linux/s390 platform, but works with
-O1.
Also it works on the linux/amd64, linux/arm64, linux/ppc64le platforms with -O1
and -O2.

1) gcc -v output:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/s390x-redhat-linux/13/lto-wrapper
Target: s390x-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --disable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu
--enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-13.0.1-20230401/obj-s390x-redhat-linux/isl-install
--enable-gnu-indirect-function --with-long-double-128 --with-arch=z13
--with-tune=z14 --enable-decimal-float --build=s390x-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.1 20230401 (Red Hat 13.0.1-0) (GCC)

2) gcc build command:
gcc -O2 belt_test.c -o belt_test

3) run command:
belt_test

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

* [Bug c/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
@ 2023-04-13  6:26 ` pinskia at gcc dot gnu.org
  2023-04-13  6:28 ` [Bug middle-end/109493] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-13  6:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
 belt_mac_st* st = &state;
 belt_mac_st* st2 = &state2;
 ((word*)(st->s))[0] = 0, ((word*)(st->s))[1] = 0;
 ((word*)(st->r))[0] = 0, ((word*)(st->r))[1] = 0;
 st->filled = 0;

I am 99% sure those are aliasing rule violations.

Does -fno-strict-aliasing help?

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
  2023-04-13  6:26 ` [Bug c/109493] " pinskia at gcc dot gnu.org
@ 2023-04-13  6:28 ` pinskia at gcc dot gnu.org
  2023-04-13  6:35 ` sjames at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-13  6:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
And in u32From too.

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
  2023-04-13  6:26 ` [Bug c/109493] " pinskia at gcc dot gnu.org
  2023-04-13  6:28 ` [Bug middle-end/109493] " pinskia at gcc dot gnu.org
@ 2023-04-13  6:35 ` sjames at gcc dot gnu.org
  2023-04-13  6:48 ` mitskevichmn at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-04-13  6:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
It's unclear to me from the reports if this started with GCC 13 or if it always
failed on s390x. Could you clarify? Thanks.

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
                   ` (2 preceding siblings ...)
  2023-04-13  6:35 ` sjames at gcc dot gnu.org
@ 2023-04-13  6:48 ` mitskevichmn at gmail dot com
  2023-04-13  6:55 ` mitskevichmn at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mitskevichmn at gmail dot com @ 2023-04-13  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Mikhail Mitskevich <mitskevichmn at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
>  belt_mac_st* st = &state;
>  belt_mac_st* st2 = &state2;
>  ((word*)(st->s))[0] = 0, ((word*)(st->s))[1] = 0;
>  ((word*)(st->r))[0] = 0, ((word*)(st->r))[1] = 0;
>  st->filled = 0;
> 
> I am 99% sure those are aliasing rule violations.
> 
> Does -fno-strict-aliasing help?

With -fno-strict-aliasing option code works as well as with -O1 option.

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
                   ` (3 preceding siblings ...)
  2023-04-13  6:48 ` mitskevichmn at gmail dot com
@ 2023-04-13  6:55 ` mitskevichmn at gmail dot com
  2023-04-13  7:25 ` mitskevichmn at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mitskevichmn at gmail dot com @ 2023-04-13  6:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Mikhail Mitskevich <mitskevichmn at gmail dot com> ---
(In reply to Sam James from comment #3)
> It's unclear to me from the reports if this started with GCC 13 or if it
> always failed on s390x. Could you clarify? Thanks.

This test works on GCC 10 and GCC 11 on s390x platform. Now we include Fedora
Rawhide with GCC 13 to our test suite, and test starts to fail.

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
                   ` (4 preceding siblings ...)
  2023-04-13  6:55 ` mitskevichmn at gmail dot com
@ 2023-04-13  7:25 ` mitskevichmn at gmail dot com
  2023-04-13  8:37 ` xry111 at gcc dot gnu.org
  2023-04-13 11:39 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mitskevichmn at gmail dot com @ 2023-04-13  7:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Mikhail Mitskevich <mitskevichmn at gmail dot com> ---
(In reply to Sam James from comment #3)
> It's unclear to me from the reports if this started with GCC 13 or if it
> always failed on s390x. Could you clarify? Thanks.

I have run this test on GCC 12 on s390x and it fails (gcc version 12.2.1
20221121 (Red Hat 12.2.1-4) (GCC) ).

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
                   ` (5 preceding siblings ...)
  2023-04-13  7:25 ` mitskevichmn at gmail dot com
@ 2023-04-13  8:37 ` xry111 at gcc dot gnu.org
  2023-04-13 11:39 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-04-13  8:37 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

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

--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Mikhail Mitskevich from comment #4)
> (In reply to Andrew Pinski from comment #1)
> >  belt_mac_st* st = &state;
> >  belt_mac_st* st2 = &state2;
> >  ((word*)(st->s))[0] = 0, ((word*)(st->s))[1] = 0;
> >  ((word*)(st->r))[0] = 0, ((word*)(st->r))[1] = 0;
> >  st->filled = 0;
> > 
> > I am 99% sure those are aliasing rule violations.
> > 
> > Does -fno-strict-aliasing help?
> 
> With -fno-strict-aliasing option code works as well as with -O1 option.

Then it's likely the code is buggy, not GCC is buggy (unless you have some
fancy type attributes on "word" or "belt_mac_st").

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

* [Bug middle-end/109493] Broken O2 optimization on s390x in GCC 13
  2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
                   ` (6 preceding siblings ...)
  2023-04-13  8:37 ` xry111 at gcc dot gnu.org
@ 2023-04-13 11:39 ` rguenth at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-13 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED
             Target|                            |s390x

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
just use memset(...) here

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

end of thread, other threads:[~2023-04-13 11:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  6:22 [Bug c/109493] New: Broken O2 optimization on s390x in GCC 13 mitskevichmn at gmail dot com
2023-04-13  6:26 ` [Bug c/109493] " pinskia at gcc dot gnu.org
2023-04-13  6:28 ` [Bug middle-end/109493] " pinskia at gcc dot gnu.org
2023-04-13  6:35 ` sjames at gcc dot gnu.org
2023-04-13  6:48 ` mitskevichmn at gmail dot com
2023-04-13  6:55 ` mitskevichmn at gmail dot com
2023-04-13  7:25 ` mitskevichmn at gmail dot com
2023-04-13  8:37 ` xry111 at gcc dot gnu.org
2023-04-13 11:39 ` rguenth 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).