From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 775D43858405; Tue, 23 Nov 2021 18:21:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 775D43858405 From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103388] New: [12 Regression] missed optimization for dead code elimination at -O3 (vs. -O2) Date: Tue, 23 Nov 2021 18:21:17 +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: 12.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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2021 18:21:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103388 Bug ID: 103388 Summary: [12 Regression] missed optimization for dead code elimination at -O3 (vs. -O2) Product: gcc Version: 12.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: --- cat case.c void foo(void); void bar(void); static int b, d, e, *c, *f =3D &d, *h =3D &b; int main() { int **i =3D &c; if (e) { e =3D *f; bar(); if (!(((i && d) + *h >=3D 1 ^ d & b) <=3D 4 | d)) foo(); } } trunk cannot eliminate the call to foo but 11.2.0 can: gcc-11.2.0 -O3 -S -o /dev/stdout case.c main: .LFB0: .cfi_startproc movl e(%rip), %ecx testl %ecx, %ecx jne .L8 xorl %eax, %eax ret .L8: pushq %rax .cfi_def_cfa_offset 16 movl d(%rip), %eax movl %eax, e(%rip) call bar xorl %eax, %eax popq %rdx .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: gcc-trunk -O3 -S -o /dev/stdout case.c main: .LFB0: .cfi_startproc movl e(%rip), %esi testl %esi, %esi jne .L10 xorl %eax, %eax ret .L10: pushq %rcx .cfi_def_cfa_offset 16 movl d(%rip), %eax movl %eax, e(%rip) call bar movl d(%rip), %edx movl b(%rip), %eax cmpl $1, %edx movl %eax, %ecx sbbl $-1, %ecx testl %ecx, %ecx setg %cl andl %edx, %eax movzbl %cl, %ecx xorl %ecx, %eax cmpl $4, %eax setle %al movzbl %al, %eax orl %edx, %eax je .L11 .L3: xorl %eax, %eax popq %rdx .cfi_remember_state .cfi_def_cfa_offset 8 ret .L11: .cfi_restore_state call foo jmp .L3 .cfi_endproc .LFE0: gcc-trunk -v Using built-in specs. Supported LTO compression algorithms: zlib zstd gcc version 12.0.0 20211123 (experimental) (GCC) Started with https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D4b3a325f07acebf47e82de2= 27ce1d5ba62f5bcae=