From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 71FF93858401; Tue, 16 Nov 2021 18:31:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71FF93858401 From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103281] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Date: Tue, 16 Nov 2021 18:31:51 +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, 16 Nov 2021 18:31:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103281 Bug ID: 103281 Summary: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) 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); static unsigned b; int main() { for (; b < 3; b++) { char c =3D b; char a =3D c ? c : c << 1; if (!(a < 1 ^ b)) 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 b(%rip), %eax cmpl $2, %eax ja .L6 testl %eax, %eax movl $1, %edx cmove %edx, %eax .L8: addl $1, %eax movl %eax, b(%rip) cmpl $2, %eax je .L8 .L6: xorl %eax, %eax ret .cfi_endproc gcc-trunk -O3 -S -o /dev/stdout case.c main: .LFB0: .cfi_startproc movl b(%rip), %eax cmpl $2, %eax ja .L13 .p2align 4,,10 .p2align 3 .L12: xorl %edx, %edx testb %al, %al setle %dl cmpl %eax, %edx je .L16 addl $1, %eax movl %eax, b(%rip) cmpl $3, %eax jne .L12 .L13: xorl %eax, %eax ret .p2align 4,,10 .p2align 3 .L16: subq $8, %rsp .cfi_def_cfa_offset 16 .L14: call foo movl b(%rip), %eax addl $1, %eax movl %eax, b(%rip) cmpl $2, %eax ja .L7 .L2: xorl %edx, %edx testb %al, %al setle %dl cmpl %eax, %edx je .L14 addl $1, %eax movl %eax, b(%rip) cmpl $3, %eax jne .L2 .L7: xorl %eax, %eax popq %rdx .cfi_def_cfa_offset 8 ret .cfi_endproc gcc-trunk -v Using built-in specs. Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.0.0 20211116 (experimental) (GCC) Started with https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D7d6979197274a662da7bdc5= 64314afe8415865c1=