From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8FD443858402; Mon, 9 Oct 2023 12:50:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FD443858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696855854; bh=lroIbH6XFYaJLZCBkDWFtbMJR6Va8xp2Ewoht5zFiWw=; h=From:To:Subject:Date:From; b=PHt+4z45zUi3vfUJkELQl6O/+hDAxnLFJiVF2w/37hna4QX3kVaxdiny1j6RcMmSr hsw0W1EEgOnjqGCO657tppn5lBY5dvM+gciu/7NOi78pY5fUQAZN56IlLNk5ERQLFQ 5ziql3/J89KJfJAWrZkvpaqAj9XXQkyOaj58lHCU= From: "iamanonymous.cs at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111739] New: incorrect code with PGO enabled Date: Mon, 09 Oct 2023 12:50:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iamanonymous.cs at gmail 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=3D111739 Bug ID: 111739 Summary: incorrect code with PGO enabled Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- ***************************************************************************= **** OS and Platform: $ uname -a: Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ***************************************************************************= **** gcc version: $ gcc -v Using built-in specs. COLLECT_GCC=3D/root/gcc_set/new_gcc/bin/gcc COLLECT_LTO_WRAPPER=3D/root/gcc_set/new_gcc/libexec/gcc/x86_64-pc-linux-gnu= /14.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=3D/root/gcc_set/new_gcc --with-gmp=3D/root/build_essential --with-mpfr=3D/root/build_essential --with-mpc=3D/root/build_essential --enable-languages=3Dc,c++ --disable-mul= tilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230719 (experimental) (GCC) git version:85da0b40538fb0d17d89de1e7905984668e3dfef ***************************************************************************= **** Program: $ cat a.c c, d, e, a; union { int f; short g } h; *j =3D &h; k(short l, short m) { return m =3D=3D 0 || l && m =3D=3D 1 ?: l / m; } n(l) { return c =3D=3D 0 ?: l / c; } main() { a =3D n(h.f++); *j =3D 0; int i =3D 0; for (; i < 2; i++) d =3D k(h.g || 0, 59376); short *b =3D &h; *b ^=3D e; printf("%d\n", h); } ***************************************************************************= **** Command Lines: # The profile directory is used to save profile information. $ gcc -O3 -w -fprofile-generate=3Dprofile a.c -o a.out $ ./a.out 0 $ gcc -O3 -w -fprofile-use=3Dprofile -Wno-missing-profile -fprofile-correct= ion a.c=20=20 -o a.out $ ./a.out 1 We can found that, the output of the executable is incorrect when the profi= le guided optimization is enabled.=