From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D40553858C53; Fri, 25 Aug 2023 06:39:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D40553858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692945579; bh=lOU3Hq488f318ZK2mCP8ZOnvEi8w6Pgnpe0lnmGt38E=; h=From:To:Subject:Date:From; b=jg4RI7EZNkk7Kr6XaV+ttV17xQ1lm3bpiZKLHLsGXJvow1jMzsFJVO8cDeLa9Nu+2 rVzGo695T8YTxsr8kj7nqQCIaygeSm3wLcIS8ILxDBKK+O1MZMcat7UeU+QKf3m6oK Wz4txsjygf84tq3oirRvfXzQwEThU6SE50XZ6Ff0= From: "jwzeng at nuaa dot edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/111151] New: [12/13/14 Regression] Wrong code at -O0 on x86_64-pc-linux-gnu Date: Fri, 25 Aug 2023 06:39:39 +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=3D111151 Bug ID: 111151 Summary: [12/13/14 Regression] Wrong code at -O0 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: --- Link to the Compiler Explorer: https://godbolt.org/z/MY4Er6b3e The following code snippet, gcc at -O0 produces the wrong code. I also comp= iled this code with almost all versions up to and including gcc-13 and got the s= ame error. $ cat test.c int printf(const char *, ...); short t =3D -32166; unsigned long long int a, b, c; int main() { a =3D 32739 > t + 4503599ULL ? 32739 : t + 4503599ULL; b =3D -10 * a; printf("%llu (Split calculation result)\n", b); c =3D -10 * (32739 > t + 4503599ULL ? 32739 : t + 4503599ULL); printf("%llu (Combine calculation result)\n", c); } $ $ gcc-tk test.c; ./a.out 18446744073664837286 (Split calculation result) 18446744073709224226 (Combine calculation result) $ $ clang-tk test.c; ./a.out 18446744073664837286 (Split calculation result) 18446744073664837286 (Combine calculation result) $ $ ccomp test.c; ./a.out 18446744073664837286 (Split calculation result) 18446744073664837286 (Combine calculation result) $ $ gcc-tk --version gcc (GCC) 14.0.0 20230823 (experimental) [master r14-3395-g6cd8527307] $ $ clang-tk --version Ubuntu clang version 18.0.0 (++20230821052626+634b2fd2cac2-1~exp1~20230821172748.738) $ $ ccomp --version The CompCert C verified compiler, version 3.12=