public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zsojka at seznam dot cz" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/40748] New: simple switch/case, if/else and arithmetics result in different code Date: Tue, 14 Jul 2009 17:09:00 -0000 [thread overview] Message-ID: <bug-40748-14164@http.gcc.gnu.org/bugzilla/> (raw) Tested r149624, 4.4.0 and 4.3.3 # ./gcc -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --enable-languages=c,c++ --prefix=/mnt/svn/gcc-trunk/build/ Thread model: posix gcc version 4.5.0 20090714 (experimental) (GCC) 4.4.0 and 4.5 have better behaviour in the case of "switch" The following code: ------------------------------- unsigned f1(unsigned i) { switch (i) { case 0: return 0; case 1: return 1; case 2: return 2; case 3: return 3; default: return 4; } } unsigned f2(unsigned i) { if (i == 0) return 0; if (i == 1) return 1; if (i == 2) return 2; if (i == 3) return 3; return 4; } unsigned f3(unsigned i) { return i < 4 ? i : 4; } ------------------------------- f1(), f2() and f3() do the same, but the resulting code differs a lot. -- Summary: simple switch/case, if/else and arithmetics result in different code Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zsojka at seznam dot cz GCC host triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40748
next reply other threads:[~2009-07-14 17:09 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-07-14 17:09 zsojka at seznam dot cz [this message] 2009-07-14 17:11 ` [Bug c/40748] " zsojka at seznam dot cz 2009-07-15 9:35 ` [Bug middle-end/40748] " rguenth at gcc dot gnu dot 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-40748-14164@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).