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/110503] New: [13/14 Regression] Dead Code Elimination Regression at -O3 since  r13-322-g7f04b0d786e
Date: Fri, 30 Jun 2023 16:34:39 +0000	[thread overview]
Message-ID: <bug-110503-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110503
           Summary: [13/14 Regression] Dead Code Elimination Regression at
                    -O3 since  r13-322-g7f04b0d786e
           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/h3G76EEW5

Given the following code:

void foo(void);
static int f = 10, g, h;
static int *i = &g, *j = &f, *k = &h;
static char(a)(int b) {
    if (!(((b) >= 1) && ((b) <= 3))) {
        __builtin_unreachable();
    }
    return 0;
}
static char(c)(char d, char e) { return d % e; }
static void l() {
    char m, n;
    unsigned o;
    int *p = &g;
    o = -19;
    for (; o > 22; o = o + 8) {
        int *q = &g;
        g = 30;
        unsigned char d = 60, e = o;
        m = d / e;
        if ((0 || *q) & m == 0)
            ;
        else {
            foo();
            n = c(0 != p, *p);
            a(n);
            *q = 0;
        }
    }
    *i = a(3);
    *k = 0 != *j;
}
int main() {
    l();
    a(h);
}

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

main:
        pushq   %rbx
        movl    $-19, %ebx
        jmp     .L5
        .p2align 4,,10
        .p2align 3
.L8:
        call    foo
        addl    $8, %ebx
.L5:
        movl    $30, g(%rip)
        cmpb    $60, %bl
        jbe     .L8
        addl    $8, %ebx
        cmpl    $5, %ebx
        jne     .L5
        movl    f(%rip), %edx
        xorl    %eax, %eax
        popq    %rbx
        movl    $0, g(%rip)
        testl   %edx, %edx
        setne   %al
        movl    %eax, h(%rip)
        xorl    %eax, %eax
        ret

gcc-12.3.0 -O3 eliminates the call to foo:

main:
        movl    f(%rip), %edx
        xorl    %eax, %eax
        movl    $0, g(%rip)
        testl   %edx, %edx
        setne   %al
        movl    %eax, h(%rip)
        xorl    %eax, %eax
        ret

Bisects to r13-322-g7f04b0d786e

             reply	other threads:[~2023-06-30 16:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30 16:34 theodort at inf dot ethz.ch [this message]
2023-06-30 21:21 ` [Bug tree-optimization/110503] " pinskia at gcc dot gnu.org
2023-06-30 21:42 ` pinskia at gcc dot gnu.org
2023-06-30 21:47 ` pinskia at gcc dot gnu.org
2023-06-30 22:29 ` pinskia at gcc dot gnu.org
2023-07-27  9:27 ` rguenth at gcc dot gnu.org
2023-08-07  9:08 ` pinskia at gcc dot gnu.org
2023-08-26  0:13 ` pinskia at gcc dot gnu.org
2024-03-08 15:28 ` law at gcc dot gnu.org
2024-03-09  7:16 ` law at gcc dot gnu.org
2024-05-21  9:16 ` [Bug tree-optimization/110503] [13/14/15 " jakub 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-110503-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).