From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9BD993858C60; Mon, 18 Sep 2023 09:45:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BD993858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695030357; bh=r/KvXu1gfwqr5z/0ExtxeFpnO9bXxHGm6x3xzpTBXYs=; h=From:To:Subject:Date:From; b=EDqxpD16vsGQbJIRIcEh7axJG86/hvE4ICzEBmZbnmTzZ5zZg5qpBwQZeo92vwPvs BR82VkF4v2wbWG+MiNtkysP4W9N1tFtHSyg9mF9f31s8CjEPWBDQhRlZqxDPlNAGe6 y/Uk6OPfRbqSSwrfNX/eOhFfGDK+0ILx7+LPpVQQ= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111456] New: [14 Regression] Dead Code Elimination Regression since r14-3719-gb34f3736356 Date: Mon, 18 Sep 2023 09:45:57 +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: theodort 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=3D111456 Bug ID: 111456 Summary: [14 Regression] Dead Code Elimination Regression since r14-3719-gb34f3736356 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: theodort at inf dot ethz.ch Target Milestone: --- https://godbolt.org/z/jqqP5baY8 Given the following code: void foo(void); static int i; static int *j =3D &i; static char l; static void(a)(char) {} static short(b)(short c, short d) { return c - d; } static short(e)(short f, int g) { return f < 0 || g < 0 || g >=3D 32 ? f : f >> g; } static short(h)(short f, int g) { return g >=3D 2 ?: f >> g; } static char k(char m, short n) { short o; int *p =3D &i; if (!(((m) >=3D 1) && ((m) <=3D 1))) { __builtin_unreachable(); } o =3D e(i, i); if (h(1, o)) ; else { m =3D 0; for (; m >=3D -20; m =3D b(m, 9)) if (a(i), n) { if (*p) ; else foo(); ; } else return l; } return i; } int main() { k(0 <=3D 0 > *j, i); } gcc-trunk -O2 does not eliminate the call to foo: main: movl i(%rip), %eax testw %ax, %ax js .L6 testl %eax, %eax jne .L6 .L9: xorl %eax, %eax ret .p2align 4,,10 .p2align 3 .L6: movswl %ax, %edx cmpw $1, %ax jg .L9 testl %edx, %edx je .L9 pushq %rbx movl $3, %ebx .L5: cmpl $0, i(%rip) je .L13 .L4: subb $1, %bl jne .L5 xorl %eax, %eax popq %rbx ret .L13: call foo jmp .L4 gcc-13.2.0 -O2 eliminates the call to foo: main: xorl %eax, %eax ret Bisects to r14-3719-gb34f3736356=