From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5FA7B3858035; Tue, 5 Sep 2023 14:56:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FA7B3858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693925814; bh=A/9TiZ6V9QqQtIhnvGOFpgJBOYYO2JHHmB5T27NePAE=; h=From:To:Subject:Date:From; b=tmfcC/1R1ZYD3/tDdtUugWdroaemy8N8+pHnW0ZaQT+cWQKMs9Ajn/bnEmq2LMPkW /y80+/rxaxcLEDu9YBaaTiJQWby2lfMnrO/uW3VgD8mMvR/jN3T1SSUWq1dtEZtP3R zadebI0df7L1k2KfjNSjBYjS74kWeXrAIoJc9vL8= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111292] New: Missed Dead Code Elimination since r14-2228-g02460c0b8c9 Date: Tue, 05 Sep 2023 14:56:54 +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: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111292 Bug ID: 111292 Summary: Missed Dead Code Elimination since r14-2228-g02460c0b8c9 Product: gcc Version: 14.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: --- https://godbolt.org/z/sxj43ojn3 Given the following code: void foo(void); static struct { int a; char b; } c; static int d, f, g; static int *e =3D &d, *h, *i; static int **j =3D &h; int main() { { short k =3D d; int l; for (; c.a; c.a--) { int **m =3D 0; int *n =3D &l; if (*e) g =3D *i !=3D 0; else __builtin_unreachable(); f =3D 8; for (; f; f--) { *n =3D c.b || k; if ((k && *i) + g) { int ***o =3D &m; *o =3D j; } else i =3D &g; } if (m =3D=3D 0 || m =3D=3D &h) ; else foo(); ; } } } gcc-trunk -O3 does not eliminate the call to foo: main: movl c(%rip), %eax pushq %rbx movzwl d(%rip), %ebx testl %eax, %eax je .L37 .p2align 4,,10 .p2align 3 .L2: movq i(%rip), %rcx xorl %esi, %esi movl (%rcx), %edx testl %edx, %edx setne %sil cmpb $0, c+4(%rip) movl %esi, g(%rip) jne .L3 testw %bx, %bx jne .L4 testl %edx, %edx jne .L5 movl $0, f(%rip) movq $g, i(%rip) .L6: subl $1, %eax movl %eax, c(%rip) jne .L2 .L37: xorl %eax, %eax popq %rbx ret .p2align 4,,10 .p2align 3 .L3: testw %bx, %bx je .L45 movl (%rcx), %esi movl %edx, %edi orl %esi, %edi je .L28 xorl %edi, %edi testl %esi, %esi je .L46 .p2align 4,,10 .p2align 3 .L23: movl $0, f(%rip) movl $h, %esi testb %dil, %dil je .L6 .L24: movq %rcx, i(%rip) .L11: testq %rsi, %rsi je .L6 cmpq $h, %rsi je .L6 call foo movl c(%rip), %eax subl $1, %eax movl %eax, c(%rip) jne .L2 jmp .L37 .p2align 4,,10 .p2align 3 .L4: testl %edx, %edx jne .L5 movl $0, f(%rip) movl (%rcx), %esi testl %esi, %esi je .L43 .L8: movl $h, %esi jmp .L11 .p2align 4,,10 .p2align 3 .L45: movl $0, f(%rip) testl %edx, %edx jne .L8 .L43: movq $g, i(%rip) jmp .L6 .p2align 4,,10 .p2align 3 .L5: movl $0, f(%rip) jmp .L6 .L28: movl $1, %edi movl $g, %ecx xorl %esi, %esi .L12: movl (%rcx), %r8d movl %edx, %r9d orl %r8d, %r9d jne .L47 movl $1, %edi movl $g, %ecx .L14: movl (%rcx), %r8d movl %edx, %r10d orl %r8d, %r10d je .L31 movl $h, %esi testl %r8d, %r8d jne .L23 .L15: movl (%rcx), %r8d movl %edx, %r11d orl %r8d, %r11d je .L32 movl $h, %esi testl %r8d, %r8d jne .L23 .L16: movl (%rcx), %r8d movl %edx, %r11d orl %r8d, %r11d je .L33 movl $h, %esi testl %r8d, %r8d jne .L23 .L18: movl (%rcx), %r8d movl %edx, %r10d orl %r8d, %r10d je .L48 testl %r8d, %r8d jne .L23 movl $h, %esi testl %edx, %edx jne .L27 .L21: movl $1, %edi movl $g, %ecx .L27: orl (%rcx), %edx jne .L23 xorl %ecx, %ecx movl %ecx, f(%rip) movl $g, %ecx jmp .L24 .L47: movl $h, %esi testl %r8d, %r8d jne .L23 jmp .L14 .L48: cmpl $0, g(%rip) je .L21 xorl %edx, %edx movl $g, %ecx movl $h, %esi movl %edx, f(%rip) jmp .L24 .L31: movl $1, %edi movl $g, %ecx jmp .L15 .L32: movl $1, %edi movl $g, %ecx jmp .L16 .L33: movl $1, %edi movl $g, %ecx jmp .L18 .L46: movl $h, %esi jmp .L12 gcc-13.2.0 -O3 eliminates the call to foo: main: movl c(%rip), %eax movzwl d(%rip), %edi testl %eax, %eax je .L13 .p2align 4,,10 .p2align 3 .L2: movq i(%rip), %rdx xorl %ecx, %ecx movl (%rdx), %esi testl %esi, %esi setne %cl movl %ecx, g(%rip) jne .L7 testw %di, %di je .L14 movl (%rdx), %edx testl %edx, %edx je .L14 .L7: movl $0, f(%rip) .L6: subl $1, %eax movl %eax, c(%rip) jne .L2 .L13: xorl %eax, %eax ret .p2align 4,,10 .p2align 3 .L14: movl $0, f(%rip) movq $g, i(%rip) jmp .L6 Bisects to r14-2228-g02460c0b8c9=