From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2382F385840A; Fri, 22 Oct 2021 09:39:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2382F385840A From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102892] New: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Date: Fri, 22 Oct 2021 09:39:03 +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: Fri, 22 Oct 2021 09:39:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102892 Bug ID: 102892 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 test.c static long b[2][1] =3D {0}; void bar(void); void foo(void); int main() { long c =3D 0; for (long a; a < 1; ++a) for (; c <=3D 1; c++) { bar(); if (1 =3D=3D b[c][0]) foo(); } } 11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot: gcc-11 -O3 -S test.c -o /dev/stdout ... main: .LFB0: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 call bar call bar xorl %eax, %eax addq $8, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc gcc-trunk-O3 -S test.c -o /dev/stdout main: .LFB0: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 xorl %ebx, %ebx call bar cmpq $1, b(,%rbx,8) je .L11 .p2align 4,,10 .p2align 3 .L3: cmpq $1, %rbx je .L12 .L5: call bar movl $1, %ebx cmpq $1, b(,%rbx,8) jne .L3 .L11: call foo cmpq $1, %rbx jne .L5 .L12: xorl %eax, %eax popq %rbx .cfi_def_cfa_offset 8 ret .cfi_endproc gcc-trunk -v Using built-in specs. Target: x86_64-pc-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.0.0 20211022 (experimental) (GCC) Introduced with https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D01b5038718056b024b370b7= 4a874fbd92c5bbab3=