From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 720333858D1E; Mon, 30 Jan 2023 13:18:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 720333858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675084697; bh=uTv9gyu0MEwqmTJ+TdoTnBVnYGYHFYd1WjNt8B6Xc+8=; h=From:To:Subject:Date:From; b=TxxwwToRXk/ivPDj1HgSK5TrCCDq4U/+CmKetN+DC2fhE2dYLyk1+VsJrOqVcqvpI qZKo6LXiS3P53m06fsXMlfSRvgdETbAtUowyMSEjUX37ui9MjJJxj8O0u0GraEGo2V S5AFvLPKMaB2JEFVDNodeKxGa28vLhqWC1UXPPyc= From: "balder at yahooinc dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: balder at yahooinc dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108599 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=3Dhaswell -mtune=3Dskylake 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=3Dhaswell -mtune=3Dskylake-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 =3D=3D stats._dead' failed. Compiler version: c++ -v Using built-in specs. COLLECT_GCC=3Dc++ COLLECT_LTO_WRAPPER=3D/opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-re= dhat-linux/12/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=3Dc,c++,fortran,lto --prefix=3D/opt/rh/gcc-toolset-12/ro= ot/usr --mandir=3D/opt/rh/gcc-toolset-12/root/usr/share/man --infodir=3D/opt/rh/gcc-toolset-12/root/usr/share/info --with-bugurl=3Dhttp://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=3Dposix --enable-checking=3Drelease --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=3Dgnu --enable-plugin --enable-initfini-array --with-isl=3D/builddir/build/BUILD/gcc-12.1.1-20220628/obj-x86_64-redhat-li= nux/isl-install --enable-offload-targets=3Dnvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=3Dgeneric --with-arch_32=3Dx86-64 --build=3Dx86_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)=20 ------------------------ Code -------------------- #include #include 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 +=3D val; return *this; } Stats hold(size_t val) { _hold +=3D 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 =3D=3D stats._used); assert(exp_hold =3D=3D stats._hold); assert(exp_dead =3D=3D stats._dead); // <=3D=3D=3D=3D=3D= Assert fails assert(exp_extra_used =3D=3D 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)); // <=3D=3D=3D= =3D=3D=3D=3D=3D=3D Causes assert to fail return 0; }=