public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sumnon at cj3 dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/65217] New: __builtin_unreachable in if statement causes bad assembly generation Date: Thu, 26 Feb 2015 07:37:00 -0000 [thread overview] Message-ID: <bug-65217-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65217 Bug ID: 65217 Summary: __builtin_unreachable in if statement causes bad assembly generation Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sumnon at cj3 dot org Test case: int expected(int n) { return n; } int test(int n) { if ((n & -n) != n) { __builtin_unreachable(); } return n; } gcc -O3 -S test.c generates this: .file "test.c" .text .p2align 4,,15 .globl expected .type expected, @function expected: .LFB0: .cfi_startproc movl %edi, %eax ret .cfi_endproc .LFE0: .size expected, .-expected .p2align 4,,15 .globl test .type test, @function test: .LFB1: .cfi_startproc movl %edi, %eax negl %eax andl %edi, %eax ret .cfi_endproc .LFE1: .size test, .-test .ident "GCC: (GNU) 4.8.3 20140911 (Red Hat 4.8.3-7)" .section .note.GNU-stack,"",@progbits These functions should generate the same assembly, since the if statement in function test does nothing that affects the return value. I have and tested this with gcc 4.8.3; a friend tested this with gcc 4.9.2 and got the same assembly.
next reply other threads:[~2015-02-26 3:15 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-02-26 7:37 sumnon at cj3 dot org [this message] 2015-02-26 7:39 ` [Bug c/65217] " pinskia at gcc dot gnu.org 2015-02-26 15:04 ` hjl at gcc dot gnu.org 2015-04-27 11:08 ` [Bug tree-optimization/65217] " rguenth at gcc dot gnu.org 2015-04-28 4:02 ` law at gcc dot gnu.org 2015-04-28 14:26 ` law 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-65217-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).