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/111326] New: [14 Regression] Dead Code Elimination Regression since r14-376-g47a76439911
Date: Thu, 07 Sep 2023 12:47:38 +0000	[thread overview]
Message-ID: <bug-111326-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111326
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-376-g47a76439911
           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/fv3szWMTE

Given the following code:

void foo(void);
static int a = 253, d, e, f, h, i, k;
static char j, m;
static short l, n;
static char(o)(char b, char c) { return b + c; }
void(p)(int);
short(q)(short);
static short(r)(int g) {
    if (!(((g) >= 253) && ((g) <= 253))) {
        __builtin_unreachable();
    }
    return 0;
}
static void s(char ab, short) {
    int ac;
    ab = 27;
    for (; ab > 13; ab = ab - 9) {
        j |= 10 | ac;
        e = 0;
        if (o(ab ^ a, d)) {
            --l;
            f = 0;
            if (a)
                ;
            else {
                p(i);
                k ^= q(0);
            }
            i = 5;
        } else {
            ac = 0;
            for (; ac <= 38; ac = ac + 5) foo();
            k = h &= 0 >= 0;
            n = 0;
        }
    }
}
static unsigned t() {
    s(m, a);
    if (l)
        ;
    else
        r(3);
    return f;
}
int main() {
    d = a;
    t();
    r(a);
    printf("", e, n);
}

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

main:
        pushq   %rbp
        movl    $253, %edx
        movl    $27, %ebp
        pushq   %rbx
        subq    $8, %rsp
        movl    $253, d(%rip)
.L5:
        movl    %ebp, %eax
        orb     $42, j(%rip)
        movl    $0, e(%rip)
        xorl    $-3, %eax
        addb    %dl, %al
        je      .L6
        subw    $1, l(%rip)
        movl    $0, f(%rip)
        movl    $5, i(%rip)
.L3:
        cmpb    $18, %bpl
        je      .L4
        movl    d(%rip), %edx
        movl    $18, %ebp
        jmp     .L5
        .p2align 4,,10
        .p2align 3
.L4:
        movswl  n(%rip), %edx
        movl    e(%rip), %esi
        movl    $.LC0, %edi
        xorl    %eax, %eax
        call    printf
        addq    $8, %rsp
        xorl    %eax, %eax
        popq    %rbx
        popq    %rbp
        ret
.L6:
        movl    $8, %ebx
.L2:
        call    foo
        call    foo
        subl    $2, %ebx
        jne     .L2
        movw    $0, n(%rip)
        movl    h(%rip), %eax
        andl    $1, %eax
        movl    %eax, h(%rip)
        movl    %eax, k(%rip)
        jmp     .L3

gcc-13.2.0 -O3 eliminates the call to foo:

main:
        subq    $8, %rsp
        movswl  n(%rip), %edx
        xorl    %esi, %esi
        xorl    %eax, %eax
        movl    $.LC0, %edi
        orb     $42, j(%rip)
        subw    $2, l(%rip)
        movl    $253, d(%rip)
        movl    $0, e(%rip)
        movl    $0, f(%rip)
        movl    $5, i(%rip)
        call    printf
        xorl    %eax, %eax
        addq    $8, %rsp
        ret

Bisects to r14-376-g47a76439911

             reply	other threads:[~2023-09-07 12:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 12:47 theodort at inf dot ethz.ch [this message]
2023-09-07 13:25 ` [Bug tree-optimization/111326] " pinskia at gcc dot gnu.org
2023-10-25 23:08 ` pinskia at gcc dot gnu.org
2024-03-07 23:21 ` law at gcc dot gnu.org
2024-05-07  7:41 ` [Bug tree-optimization/111326] [14/15 " 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-111326-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).