From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BBF73858D28; Thu, 2 Nov 2023 06:30:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BBF73858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698906645; bh=wqeFfQoneZZETgkMjWoGyUzQHuF4hIeBI5+CKRjOwgQ=; h=From:To:Subject:Date:From; b=sF8f0eGkAOnPkol5TzLi9xjI1LkEGkoVhPTD1UKZMQ0QHWvEH+0eJNzY39fyQnwY9 tp163+X0YM+MZdtdcf5I2qAf4DOo2x92GgCm2VlFPkDnXLKlUj0UbzdHG5GgtFPV0u 6aaWTAomLb9wzIOiSkf5SUMySfs4U4Pz8aLD5fMM= From: "jwzeng at nuaa dot edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112344] New: [14 Regression] Wrong code at -O2 on x86_64-pc-linux-gnu Date: Thu, 02 Nov 2023 06:30:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jwzeng at nuaa dot edu.cn 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=3D112344 Bug ID: 112344 Summary: [14 Regression] Wrong code at -O2 on x86_64-pc-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jwzeng at nuaa dot edu.cn Target Milestone: --- I compiled the following code with gcc at -O2, and it produces the wrong co= de.=20 The correct output result should be 13, but 73 was output under -O2.=20 This bug seems to only exist on gcc-trunk. The gcc-tk used below is the earliest version I can use that triggers this bug. Compiler explorer: https://godbolt.org/z/8hq64asT5 ```c $ cat test.c int printf(const char *, ...); int a; void b() { long c =3D 3; unsigned int d =3D 50253292; int e =3D 2147483648; for (; a < 5; a++) do { e +=3D 4; d -=3D c; } while (e < 20); printf("%d\n", d); } int main() { b(); } $ $ gcc-tk test.c -O2; ./test.c 73 $ $ gcc-tk test.c -O0; ./test.c 13 $ gcc-tk test.c -O1; ./test.c 13 $ gcc-tk test.c -O3; ./test.c 13 $ gcc-tk test.c -Os; ./test.c 13 $ ccomp test.c -O1; ./a.out 13 $ $ gcc-tk --version gcc (GCC) 14.0.0 20230922 (experimental) [master r14-4213-gd35e12e1c0] Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ $ ccomp --version The CompCert C verified compiler, version 3.12 ```=