From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9825B3858D1E; Mon, 26 Jun 2023 15:06:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9825B3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687792003; bh=Qke4RC42oRiC/xq5oY4szwxa6+VyL1H60rkZakwQp5A=; h=From:To:Subject:Date:From; b=Cs5RszhBf8YBAyd1SLcZl3oSY7yrS45o5qRHkx2mgtNe5o7d1ak2p3PJTgvFC1rqA zf7L53TeXq0XyncEAxZEnMg0uUd0HReYYOw6y7Kq5xTc/zJoo1A/xDYp9XtnhISLo5 vwgNAb2QPiKp+g0qyEMPRdtET1hIkHcjzwTimtEo= From: "theodort at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110414] New: [14 Regression] Dead Code Elimination Regression since r14-1127-g9e2017ae6ac Date: Mon, 26 Jun 2023 15:06:40 +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=3D110414 Bug ID: 110414 Summary: [14 Regression] Dead Code Elimination Regression since r14-1127-g9e2017ae6ac 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/5E795dPvY Given the following code: void foo(void); static int a, b, e, l, m, n; static int *c =3D &a, *j; static int **d =3D &c; static int ***f; void __assert_fail(char *, char *, int, char *) __attribute__((__noreturn__= )); static void g(char) { if (c =3D=3D &b || c =3D=3D &a) ; else __assert_fail("", "", 3, __PRETTY_FUNCTION__); } static void h(); static int *i(); static short k() { j =3D i(); h(); **f =3D &e; if (c =3D=3D &b || c =3D=3D &a || c =3D=3D 0) __assert_fail("", "", 6, __PRETTY_FUNCTION__); return 0; } static void h() { if (l) { for (; l; l =3D l - 8) *d =3D &m; if (c =3D=3D &a) ; else __assert_fail("", "", 9, __PRETTY_FUNCTION__); } if (c =3D=3D &b || c =3D=3D &a || c =3D=3D 0) ; else { foo(); __assert_fail("", "", 8, __PRETTY_FUNCTION__); } } static int *i() { if (c =3D=3D &b || c =3D=3D &a) ; else { __builtin_unreachable(); __assert_fail("", "", 6, __PRETTY_FUNCTION__); } return &n; } int main() { g(a && k()); } gcc-trunk -Os does not eliminate the call to foo: main: pushq %rcx cmpl $0, a(%rip) je .L2 movl l(%rip), %edx testl %edx, %edx je .L3 movl %edx, %eax movl $__PRETTY_FUNCTION__.1, %ecx movq $m, c(%rip) shrl $3, %eax imull $-8, %eax, %eax addl %edx, %eax movl $9, %edx movl %eax, l(%rip) jmp .L7 .L3: movq c(%rip), %rax cmpq $a, %rax sete %dl cmpq $b, %rax sete %cl orb %cl, %dl jne .L4 testq %rax, %rax je .L4 call foo movl $__PRETTY_FUNCTION__.1, %ecx movl $8, %edx .L7: movl $.LC0, %esi movq %rsi, %rdi call __assert_fail .L4: movl $__PRETTY_FUNCTION__.2, %ecx movl $6, %edx jmp .L7 .L2: movq c(%rip), %rax cmpq $a, %rax je .L5 cmpq $b, %rax je .L5 movl $__PRETTY_FUNCTION__.0, %ecx movl $3, %edx jmp .L7 .L5: xorl %eax, %eax popq %rdx ret gcc-13.1.0 -Os eliminates the call to foo: main: pushq %rcx movq c(%rip), %rdx cmpq $a, %rdx sete %al cmpq $b, %rdx sete %dl orl %edx, %eax cmpl $0, a(%rip) je .L2 movl l(%rip), %edx testl %edx, %edx je .L3 movl %edx, %eax movl $__PRETTY_FUNCTION__.1, %ecx movq $m, c(%rip) shrl $3, %eax imull $-8, %eax, %eax addl %edx, %eax movl $9, %edx movl %eax, l(%rip) jmp .L7 .L2: testb %al, %al jne .L5 movl $__PRETTY_FUNCTION__.0, %ecx movl $3, %edx .L7: movl $.LC0, %esi movq %rsi, %rdi call __assert_fail .L3: movl $__PRETTY_FUNCTION__.2, %ecx movl $6, %edx jmp .L7 .L5: xorl %eax, %eax popq %rdx ret Bisects to r14-1127-g9e2017ae6ac=