From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9C0D03858D28; Fri, 13 Oct 2023 15:46:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C0D03858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697211975; bh=ayB8VmAikKS/whsT6q4GL+2r7whs40iV2DQWJhHS1Hc=; h=From:To:Subject:Date:From; b=EdKEci76lomDBj/k8aUU76cctij7gRsuiECdnzXZ3EZLSjnXX/RqX3cPMkp7B/N0U 56YE8QxV4/GEqwSDJ1gjHOkB7Qi8yTfwdkVeI0+XnBbhqdGxU/lchDjtBJfLkf/mW3 LDCKraTqBD0u7F1Qo61RvV2gSkLmt3xfG0jtw8UU= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111799] New: [14 Regression] Missed Dead Code Elimination since r14-2365-g2e406f0753e Date: Fri, 13 Oct 2023 15:46:14 +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=3D111799 Bug ID: 111799 Summary: [14 Regression] Missed Dead Code Elimination since r14-2365-g2e406f0753e 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/bqcvMcbqn Given the following code: void foo(void); static struct d { short e; } g =3D {205}, *h =3D &g; static int i; static int *j, *a =3D &i; static int **k =3D &j; static int ****l; static int *****m; static char(n)(char b, char c) { return b + c; } static char(o)(char b, char c) { return b * c; } static short(p)(short f) { if (!(((f) >=3D 1) && ((f) <=3D 65459))) { __builtin_unreachable(); } return 0; } static int *q(short); static void s(struct d) { *k =3D q(i); } static int *q(short ad) { int b =3D *a; ad =3D -21; for (; ad; ad =3D n(ad, 7)) p((ad ^ b && *a) <=3D *a); return *k; } int main() { i =3D 0; for (;; i =3D 1) { q(3); char r =3D o(126 | 1, g.e); p(r); s(*h); if (i) break; m =3D &l; } if (m) ; else foo(); ; } gcc-trunk -O2 does not eliminate the call to foo: main: movl $2, %esi xorl %ecx, %ecx xorl %r9d, %r9d movl $8, %edi movl $0, i(%rip) .p2align 4,,10 .p2align 3 .L10: movl $-21, %eax .L2: testl %ecx, %ecx je .L29 leal 7(%rax), %edx movsbw %dl, %r8w testb %dl, %dl je .L23 .L5: movl $8, %eax cmpb $1, %dl je .L2 movl %r8d, %eax leal 7(%rax), %edx movsbw %dl, %r8w testb %dl, %dl jne .L5 .p2align 4,,10 .p2align 3 .L23: movl $-21, %eax addb $7, %al je .L30 .L9: movsbl %al, %edx cmpl %edx, %ecx cmove %edi, %eax cbtw addb $7, %al jne .L9 .L30: cmpl $1, %esi je .L31 movl $1, %esi movl $1, %ecx movl $1, %r9d jmp .L10 .p2align 4,,10 .p2align 3 .L29: testb $1, %al je .L4 leal 7(%rax), %edx movsbw %dl, %ax testb %dl, %dl je .L23 .L4: leal 14(%rax), %edx movsbw %dl, %ax testb %dl, %dl jne .L4 jmp .L23 .p2align 4,,10 .p2align 3 .L31: testb %r9b, %r9b je .L11 movq $l, m(%rip) movl %ecx, i(%rip) .L25: xorl %eax, %eax ret .L11: cmpq $0, m(%rip) jne .L25 pushq %rax call foo xorl %eax, %eax popq %rdx ret gcc-13.2.0 -O2 eliminates the call to foo: main: movq $l, m(%rip) xorl %eax, %eax movl $1, i(%rip) ret Bisects to r14-2365-g2e406f0753e=