From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 86F1C3858CDA; Tue, 10 Jan 2023 12:21:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86F1C3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673353315; bh=k4tesSZNcf+0F5K4y8gtIg3YRt30lWjt5PyhUnQ9n+Q=; h=From:To:Subject:Date:From; b=DU1dp3E0q/d6X02fX1tMqKAgAKWF3ubgvb+Nnh3PjmQrmaFxu+J1i24Lgcv+rxqt8 UFr0d2wqrSib3nM9ygo+Jdom8NTuX2jOsP52zOKyxTfhMMsMFmw8FrE7j4eCXegpq2 q/y/EWY2wLUDH+uQpOjyslqM2OB8MmrySsIIxjsI= From: "yann at ywg dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108352] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) Date: Tue, 10 Jan 2023 12:21:55 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yann at ywg dot 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 attachments.created 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=3D108352 Bug ID: 108352 Summary: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: yann at ywg dot ch Target Milestone: --- Created attachment 54227 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54227&action=3Dedit Code as file cat case.c #30 long a; int b; void bar64_(void); void foo(); int main() { char c =3D 0; unsigned d =3D 10; int e =3D 2; for (; d; d--) { bar64_(); b =3D d; e && (c =3D (e =3D 0) !=3D 4) > 1; } if (c < 1) foo(); a =3D b; } `gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2` can not eliminate `foo` but `gcc-releases/gcc-12.2.0 -O2` can. `gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2 -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB0: .cfi_startproc pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 movl $1, %r13d pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 movl $2, %r12d pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 xorl %ebp, %ebp pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 movl $10, %ebx subq $8, %rsp .cfi_def_cfa_offset 48 .p2align 4,,10 .p2align 3 .L3: call bar64_ testl %r12d, %r12d movl %ebx, b(%rip) cmovne %r13d, %ebp xorl %r12d, %r12d subl $1, %ebx jne .L3 movl $1, %eax testb %bpl, %bpl je .L10 .L4: movq %rax, a(%rip) addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 xorl %eax, %eax popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L10: .cfi_restore_state xorl %eax, %eax call foo movslq b(%rip), %rax jmp .L4 ---------- END OUTPUT --------- `gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB0: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movl $10, %ebx call bar64_ movl $10, %eax jmp .L3 .p2align 4,,10 .p2align 3 .L6: call bar64_ movl %ebx, %eax .L3: movl %eax, b(%rip) subl $1, %ebx jne .L6 movq $1, a(%rip) xorl %eax, %eax popq %rbx .cfi_def_cfa_offset 8 ret ---------- END OUTPUT --------- Bisects to: https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3Dd86d81a449c03641e079f23= a2b3e1b2279a162fe=