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/110080] [13/14 Regression] Missed Dead Code Elimination at -Os when using __builtin_unreachable since r13-6945-g429a7a88438
Date: Thu, 01 Jun 2023 14:02:32 +0000	[thread overview]
Message-ID: <bug-110080-4-0wb5pekQAN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110080-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Theodoros Theodoridis <theodort at inf dot ethz.ch> ---
Oops, the first code snippet is wrong in the original post: 

void foo(void);
static unsigned char a = 131;
static int *b;
static int **c = &b;
static void d(int e, unsigned f) {
    int *g;
    if (!e){ // <------------------------ if (!e) is correct
        for (; a; ++a)
            for (e = 0; 0;)
                ;
        g = &e;
        int **h = &g;
        if (**h) {
            foo();
        }
    }
    *c = &e;
}
int main() { d(4 & a, a); }

this is also the correct assembly for gcc trunk/13.1/12.3 at -Os:

main:
        movb    a(%rip), %al
        testb   $4, %al
        jne     .L5
        xorl    %edx, %edx
.L2:
        testb   %al, %al
        je      .L12
        incl    %eax
        movb    $1, %dl
        jmp     .L2
.L12:
        testb   %dl, %dl
        je      .L5
        movb    $0, a(%rip)
.L5:
        leaq    -4(%rsp), %rax
        movq    %rax, b(%rip)
        xorl    %eax, %eax
        ret
a:
        .byte   -125


the code with the _builtin_unreachable and the rest are correct

  reply	other threads:[~2023-06-01 14:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 13:54 [Bug tree-optimization/110080] New: " theodort at inf dot ethz.ch
2023-06-01 14:02 ` theodort at inf dot ethz.ch [this message]
2023-06-02  7:53 ` [Bug tree-optimization/110080] " rguenth at gcc dot gnu.org
2023-07-27  9:26 ` rguenth at gcc dot gnu.org
2023-08-21 23:20 ` pinskia at gcc dot gnu.org
2023-08-21 23:21 ` pinskia at gcc dot gnu.org
2023-09-19 14:30 ` cvs-commit at gcc dot gnu.org
2023-09-19 15:03 ` amacleod at redhat dot com

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-110080-4-0wb5pekQAN@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).