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/110361] New: [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-2020-g16b013c9d9b Date: Thu, 22 Jun 2023 11:40:40 +0000 [thread overview] Message-ID: <bug-110361-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110361 Bug ID: 110361 Summary: [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r13-2020-g16b013c9d9b 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/qab3679sq Given the following code: void foo(void); static int a, b, d, p, k; static int *c, *e, *g; static short f; static unsigned h; static int **i = &c, **o = &g; void __assert_fail() __attribute__((__noreturn__)); static void j(char, unsigned r) { h = r == 0 ?: 2 % r; int l = h; if (!(((l) >= 1) && ((l) <= 1))) { __builtin_unreachable(); } int m; *i = &m; } static int *n(); static short q(short t) { *o = &p; return t; } static unsigned s() { int *j = n(); if (e == 0 || e == &a || e == &d) ; else __assert_fail(); return *j; } static int *n() { if (b) { if (c) __assert_fail(); e = 0; } return &k; } int main() { j(q(s()), f); if (e == 0 || e == &a || e == &d) ; else foo(); f = 0; } gcc-trunk -O2 does not eliminate the call to foo: main: subq $24, %rsp movq e(%rip), %rax movswl f(%rip), %edx testq %rax, %rax je .L2 cmpq $a, %rax je .L4 cmpq $d, %rax jne .L17 .L4: movq $p, g(%rip) testl %edx, %edx je .L18 leaq 12(%rsp), %rdx movq %rdx, c(%rip) cmpq $a, %rax je .L5 cmpq $d, %rax je .L5 call foo .L5: xorl %eax, %eax movw %ax, f(%rip) xorl %eax, %eax addq $24, %rsp ret .L18: leaq 12(%rsp), %rax movq %rax, c(%rip) jmp .L5 .L2: movq $p, g(%rip) leaq 12(%rsp), %rax movq %rax, c(%rip) jmp .L5 .L17: xorl %eax, %eax call __assert_fail gcc-12.3.0 -O2 eliminates the call to foo: main: subq $24, %rsp movq e(%rip), %rax testq %rax, %rax je .L2 cmpq $a, %rax je .L2 cmpq $d, %rax jne .L14 .L2: movq $p, g(%rip) leaq 12(%rsp), %rax movq %rax, c(%rip) xorl %eax, %eax movw %ax, f(%rip) xorl %eax, %eax addq $24, %rsp ret .L14: xorl %eax, %eax call __assert_fail Bisects to r13-2020-g16b013c9d9b
next reply other threads:[~2023-06-22 11:40 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-22 11:40 theodort at inf dot ethz.ch [this message] 2023-06-22 12:58 ` [Bug tree-optimization/110361] " rguenth at gcc dot gnu.org 2023-07-27 9:27 ` rguenth at gcc dot gnu.org 2023-08-07 9:05 ` pinskia at gcc dot gnu.org 2024-03-08 15:30 ` law at gcc dot gnu.org 2024-05-21 9:16 ` [Bug tree-optimization/110361] [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-110361-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: linkBe 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).