public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "theodort at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110963] New: [14 Regression] Dead Code Elimination Regression since r14-2946-g46c8c225455
Date: Wed, 09 Aug 2023 19:42:55 +0000	[thread overview]
Message-ID: <bug-110963-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110963

            Bug ID: 110963
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-2946-g46c8c225455
           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/devdMf1qd

Given the following code:

void foo(void);
static int c = 76, f, g;
static int *h, *j, *k = &g;
static int **i = &h;
static short a;
static char(l)(char b) {
    if (!(((b) >= 77) && ((b) <= 77))) {
        __builtin_unreachable();
    }
    return 0;
}
static short(m)(short d, short e) { return d + e; }
static short n(char) {
    j = *i;
    if (j == 0)
        ;
    else
        *i = 0;
    *k = 0;
    return 0;
}
static char o() {
    l(0);
    return 0;
}
static char p(int ad) {
    a = m(!0, ad);
    l(a);
    if (f) {
        *i &&n(o());
        *i = 0;
    } else
        n(0);
    if (h == &f || h == 0)
        ;
    else
        foo();
    return 0;
}
int main() {
    p(c);
    c = 8;
}

gcc-trunk -O3 does not eliminate the call to foo:

main:
        movl    f(%rip), %edi
        testl   %edi, %edi
        je      .L11
.L7:
        movl    $8, c(%rip)
        xorl    %eax, %eax
        ret
.L11:
        cmpq    $0, h(%rip)
        je      .L4
        xorl    %esi, %esi
        movq    %rsi, h(%rip)
.L4:
        movq    h(%rip), %rax
        xorl    %ecx, %ecx
        movl    %ecx, g(%rip)
        testq   %rax, %rax
        je      .L7
        cmpq    $f, %rax
        je      .L7
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        movl    $8, c(%rip)
        popq    %rdx
        ret

gcc-13.2.0 -O3 eliminates the call to foo:

main:
        movl    f(%rip), %ecx
        movq    h(%rip), %rax
        testl   %ecx, %ecx
        jne     .L3
        testq   %rax, %rax
        je      .L4
        xorl    %edx, %edx
        movq    %rdx, h(%rip)
.L4:
        xorl    %eax, %eax
        movl    %eax, g(%rip)
.L3:
        movl    $8, c(%rip)
        xorl    %eax, %eax
        ret

Bisects to r14-2946-g46c8c225455

             reply	other threads:[~2023-08-09 19:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 19:42 theodort at inf dot ethz.ch [this message]
2023-08-09 19:43 ` [Bug tree-optimization/110963] " pinskia at gcc dot gnu.org
2023-08-09 19:52 ` pinskia at gcc dot gnu.org
2023-08-10  6:51 ` rguenth at gcc dot gnu.org
2023-08-10 11:18 ` rguenth at gcc dot gnu.org
2023-08-10 11:47 ` rguenth at gcc dot gnu.org
2023-08-10 12:13 ` theodort at inf dot ethz.ch
2023-08-10 12:20 ` rguenther at suse dot de
2023-08-10 12:24 ` hubicka at gcc dot gnu.org
2023-08-15  9:23 ` cvs-commit at gcc dot gnu.org
2023-08-15  9:24 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-110963-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).