From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25E2B385697B; Fri, 7 Jul 2023 08:03:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25E2B385697B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688716988; bh=cWK2brYKGywA+BZeEUqeNY3fdsKQDxjvH+Cdi/eM6AU=; h=From:To:Subject:Date:From; b=qvXtnaKgn99EwP4V4ZxUJ/j6M42RbXdApQ30IkICZSoU0ufuuH9jsUq7HxAXx0a+9 1tz2PL1kqGk3xKiWI8u29AY7JEYE4RKLQuWFM4EXeSNvutVcyJKSIFTOFzX3MLdYsW G67Cn+EYe1mXsq+N0qlyEA2kxa65PjplVXkJC4gE= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110582] New: Wrong code at -O2/3 on x86_64-linux-gnu Date: Fri, 07 Jul 2023 08:03:05 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch 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=3D110582 Bug ID: 110582 Summary: Wrong code at -O2/3 on x86_64-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- This seems to be a recent regression. gcc at -O2 and -O3 produce wrong code. Compiler explorer: https://godbolt.org/z/qWxPW34ch $ cat a.c int a, b; int main() { char c =3D a =3D 0; for (; c !=3D -3; c++) { int d =3D 2; d ^=3D 2 && a; b =3D a =3D=3D 0 ? d : d / a; a =3D b; } for (; (1 + 95 << 24) + b + 1 + 686658714L + b - 2297271457;) ; } $ $ gcc-tk -O0 a.c && ./a.out $ $ gcc-tk -O2 a.c $=20 $ ./a.out Killed $ $ gcc-tk -v Using built-in specs. COLLECT_GCC=3Dgcc-tk COLLECT_LTO_WRAPPER=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-55900= 189ab517906efe08f8d17f3e4a310ee7fff/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/= lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --disable-bootstrap --enable-languages=3Dc,c++ --prefix=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-55900189ab517906= efe08f8d17f3e4a310ee7fff Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20230707 (experimental) (GCC) $=