public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: fleming.feng@intel.com To: gcc-gnats@gcc.gnu.org Cc: eddie.dong@intel.com Subject: optimization/10562: Code segment optimization incorrectly disappeared with -O2 option Date: Wed, 30 Apr 2003 06:16:00 -0000 [thread overview] Message-ID: <20030430061212.29294.qmail@sources.redhat.com> (raw) >Number: 10562 >Category: optimization >Synopsis: Code segment optimization incorrectly disappeared with -O2 option >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Apr 30 06:16:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: fleming.feng@intel.com >Release: gcc-3.2 20020903 >Organization: >Environment: Red Hat Linux 8.0 3.2-7 >Description: When I compile the following code with a header file and a C file like following: test.h #define cpu_online_map 1 static inline unsigned int generic_hweight32(unsigned int w) { unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); res = (res & 0x33333333) + ((res >> 2) & 0x33333333); res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); return (res & 0x0000FFFF) + ((res>>16) & 0x0000FFFFF); } #define hweight32(x) generic_hweight32(x) static inline unsigned int num_online_cpus(void) { return hweight32(cpu_online_map); } test.c #include <stdio.h> #include "test.h" int main(int argc, char* argv[]) { int i; for(i = 0; i < num_online_cpus(); i++){ printf("gcc compiled correctly!\n"); } return 0; } The code in the "for" loop should at least executed one time! Because it equals to: for(i = 0; i < 1; i ++){ .... } but if it is compiled with -O2 option the code segment in "for" loop will not be executed. Using objdump to disassembly the output file, it can be found the code segment disappeared. If only use -O option, the result is correct. In fact the code in header file comes from linux kernel 2.4.19. And the bug is found during compile a kernel mode driver. This also happens on arm-linux-gcc version 3.2.1 which is a cross compile tool chain for ARM platform. >How-To-Repeat: Just compile the code in description with -O2 option and execute the output file. >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2003-04-30 6:16 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-04-30 6:16 fleming.feng [this message] 2003-04-30 10:56 Falk Hueffner 2003-04-30 13:55 bangerth
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=20030430061212.29294.qmail@sources.redhat.com \ --to=fleming.feng@intel.com \ --cc=eddie.dong@intel.com \ --cc=gcc-gnats@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).