From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6FAE53858D28; Mon, 17 Oct 2022 12:06:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FAE53858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666008369; bh=RPHWceuykEXC95D2xdLX0auzFe5dd9xTjPVVuPIy6N0=; h=From:To:Subject:Date:From; b=QZLKArpFi3S/uuYfQ7D04S16dJBV40uq75kfkxtkDoxakSeV22ZGEuSo4YXCat9AQ 88k8rL5m0dkuWeuOiZtL56AQWSZ0vmf5k0ZR7vPFhgC9iE/2WHrq+OyDBLV/1toFnz SmjP0AC/izg3g3kJfYCu7CnnjcMpekzAC/J88pBg= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107293] New: Wrong code at -Os on x86_64-linux-gnu Date: Mon, 17 Oct 2022 12:06:09 +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: 13.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=3D107293 Bug ID: 107293 Summary: Wrong code at -Os on x86_64-linux-gnu Product: gcc Version: 13.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: --- % gcc-tk -v Using built-in specs. COLLECT_GCC=3Dgcc-tk COLLECT_LTO_WRAPPER=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-acdb2= 4166d13d87c374e578d2ad5d58249171930/libexec/gcc/x86_64-pc-linux-gnu/13.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-acdb24166d13d87c= 374e578d2ad5d58249171930 Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221017 (experimental) (GCC) % % gcc-tk -w -O0 a.c && ./a.out 1 % gcc-tk -w -Os a.c && ./a.out 0 % cat a.c short a; int b[1]; int c(int p) { return (p < 0) ? 0 : 10 + ((p / 100 - 16) / 4); } void f(int n) { while (1) { int m =3D n; while ((m ) ) m /=3D 2; break; } } void g() { int h =3D a =3D 0; for (; h + a <=3D 0; a++) { if (b[c(a - 6)]) break; f(a); } } int main() { g(); __builtin_printf("%d\n", a); } % Compiler explorer: https://godbolt.org/z/e7sssT7cq=