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/111457] New: [14 Regression] Dead Code Elimination Regression since r14-3407-g936a12331a2
Date: Mon, 18 Sep 2023 09:50:53 +0000	[thread overview]
Message-ID: <bug-111457-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111457
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-3407-g936a12331a2
           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/j4M8z8MzK

Given the following code:

void foo(void);
static int a, b, c, d, h;
static short i;
static void e(int f) {
    int g = -16;
    for (; g != -6; g = g + 5) {
        b = 6;
        if (!(((f) >= 1) && ((f) <= 26))) {
            __builtin_unreachable();
        }
        f = 0;
        for (; f < 26; ++f)
            if (a) {
                foo();
                break;
            }
        d = 0;
    }
}
int main() {
    a = 0;
    e(0 == i);
    h = d;
    c = b;
}

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

main:
        movl    $0, a(%rip)
        pushq   %rbx
        movl    $2, %ebx
.L3:
        movl    $6, b(%rip)
        movl    a(%rip), %eax
        testl   %eax, %eax
        je      .L2
        call    foo
.L2:
        movl    $0, d(%rip)
        cmpl    $1, %ebx
        jne     .L4
        xorl    %eax, %eax
        popq    %rbx
        ret
        .p2align 4,,10
        .p2align 3
.L4:
        movl    $1, %ebx
        jmp     .L3

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        movl    $0, a(%rip)
        xorl    %eax, %eax
        movl    $6, b(%rip)
        movl    $0, d(%rip)
        ret

Bisects to r14-3407-g936a12331a2

             reply	other threads:[~2023-09-18  9:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18  9:50 theodort at inf dot ethz.ch [this message]
2023-09-18 10:40 ` [Bug tree-optimization/111457] " rguenth at gcc dot gnu.org
2023-11-24  4:39 ` pinskia at gcc dot gnu.org
2024-02-13 15:34 ` pheeck 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-111457-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).