public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "balder at yahooinc dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108599] New: Incorrect code generation newer intel architectures for gcc 12 and 13
Date: Mon, 30 Jan 2023 13:18:16 +0000	[thread overview]
Message-ID: <bug-108599-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108599
           Summary: Incorrect code generation newer intel architectures
                    for gcc 12 and 13
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: balder at yahooinc dot com
  Target Milestone: ---

The code fragment below generates incorrect code for some architectures.

It works fine when compiled with
c++ -Wall -Wextra -O2 -march=haswell -mtune=skylake test.cpp && ./a.out

Changing -mtune to skylake-avx512 makes it fail.
It also fails cascadelake and icelake-client and icelake-server.
It fails with both -O2 and -O3, but works fine with -O1 and -Og.

c++ -Wall -Wextra -O2 -march=haswell -mtune=skylake-avx512 test.cpp && ./a.out
a.out: test.cpp:23: void assert_stats(size_t, size_t, size_t, size_t, Stats):
Assertion `exp_dead == stats._dead' failed.

Compiler version:
c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,lto --prefix=/opt/rh/gcc-toolset-12/root/usr
--mandir=/opt/rh/gcc-toolset-12/root/usr/share/man
--infodir=/opt/rh/gcc-toolset-12/root/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-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-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-12.1.1-20220628/obj-x86_64-redhat-linux/isl-install
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-offload-defaulted --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.1 20220628 (Red Hat 12.1.1-3) (GCC) 

------------------------ Code --------------------
#include <cstddef>
#include <cassert>

struct Stats
{
    size_t _used;
    size_t _hold;
    size_t _dead;
    size_t _extra_used;
    Stats() : _used(0), _hold(0), _dead(0), _extra_used(0) {}
    Stats used(size_t val) { _used += val; return *this; }
    Stats hold(size_t val) { _hold += val; return *this; }
};

void
assert_stats(size_t exp_used, size_t exp_hold, size_t exp_dead,
             size_t exp_extra_used, const Stats stats)
{
    assert(exp_used == stats._used);
    assert(exp_hold == stats._hold);
    assert(exp_dead == stats._dead);                // <===== Assert fails
    assert(exp_extra_used == stats._extra_used);
}

int main(int , char* [])
{
    assert_stats(16, 0, 0, 0, Stats().used(16).hold(0));
    assert_stats(16, 16, 0, 0, Stats().used(16).hold(16));    // <=========
Causes assert to fail
    return 0;
}

             reply	other threads:[~2023-01-30 13:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 13:18 balder at yahooinc dot com [this message]
2023-01-30 13:20 ` [Bug c++/108599] " balder at yahooinc dot com
2023-01-30 13:32 ` [Bug target/108599] " balder at yahooinc dot com
2023-01-30 13:49 ` [Bug target/108599] [12/13 Regression] Incorrect code generation newer intel architectures jakub at gcc dot gnu.org
2023-01-30 14:00 ` jakub at gcc dot gnu.org
2023-01-30 14:10 ` jakub at gcc dot gnu.org
2023-01-30 14:31 ` jakub at gcc dot gnu.org
2023-01-30 15:17 ` rguenth at gcc dot gnu.org
2023-01-30 15:19 ` jakub at gcc dot gnu.org
2023-01-31  9:12 ` cvs-commit at gcc dot gnu.org
2023-01-31  9:14 ` [Bug target/108599] [12 " jakub at gcc dot gnu.org
2023-02-09 11:54 ` balder at yahooinc dot com
2023-02-09 12:02 ` jakub at gcc dot gnu.org
2023-02-10 17:46 ` cvs-commit at gcc dot gnu.org
2023-02-10 18:01 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108599-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).