From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0BB58385481D; Mon, 8 Mar 2021 20:24:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BB58385481D From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99473] New: redundant conditional zero-initialization not eliminated Date: Mon, 08 Mar 2021 20:24:43 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org 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: Mon, 08 Mar 2021 20:24:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99473 Bug ID: 99473 Summary: redundant conditional zero-initialization not eliminated Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- All three functions below should result in equivalently optimal code (and, ideally IL) but only g1() and g3() result in the same assembly, and only g1= () result in optimal, branchless GIMPLE. $ cat x.c && gcc -O2 -S -Wall -o/dev/stdout x.c void f (int*); void g1 (int i) { int x; if (i) x =3D i; else x =3D 0; f (&x); } void g2 (int i) { int x; if (i) { x =3D i; f (&x); } else { x =3D 0; f (&x); } } void g3 (int i) { int x =3D 0; if (i) x =3D i; f (&x); } .file "x.c" .text .p2align 4 .globl g1 .type g1, @function g1: .LFB0: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 movl %edi, 12(%rsp) leaq 12(%rsp), %rdi call f addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size g1, .-g1 .p2align 4 .globl g2 .type g2, @function g2: .LFB1: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 testl %edi, %edi je .L5 movl %edi, 12(%rsp) leaq 12(%rsp), %rdi call f addq $24, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L5: .cfi_restore_state leaq 12(%rsp), %rdi movl $0, 12(%rsp) call f addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE1: .size g2, .-g2 .p2align 4 .globl g3 .type g3, @function g3: .LFB2: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 movl %edi, 12(%rsp) leaq 12(%rsp), %rdi call f addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE2: .size g3, .-g3 .ident "GCC: (GNU) 11.0.1 20210308 (experimental)" .section .note.GNU-stack,"",@progbits=