public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/10562: Code segment optimization incorrectly disappeared with -O2 option
@ 2003-04-30 13:55 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-04-30 13:55 UTC (permalink / raw)
  To: eddie.dong, fleming.feng, gcc-bugs, gcc-prs, nobody

Synopsis: Code segment optimization incorrectly disappeared with -O2 option

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Wed Apr 30 13:55:58 2003
State-Changed-Why:
    I can confirm that it has been fixed between 3.2 and 3.2.3
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10562


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: optimization/10562: Code segment optimization incorrectly disappeared with -O2 option
@ 2003-04-30 10:56 Falk Hueffner
  0 siblings, 0 replies; 3+ messages in thread
From: Falk Hueffner @ 2003-04-30 10:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/10562; it has been noted by GNATS.

From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: fleming.feng@intel.com
Cc: gcc-gnats@gcc.gnu.org, eddie.dong@intel.com
Subject: Re: optimization/10562: Code segment optimization incorrectly disappeared with -O2 option
Date: 30 Apr 2003 12:51:30 +0200

 fleming.feng@intel.com writes:
 
 > The code in the "for" loop should at least executed one time!  [...]
 > but if it is compiled with -O2 option the code segment in "for" loop
 > will not be executed.
 
 This sounds a lot like a bug that was recently fixed (10171), and I
 cannot reproduce it with gcc 3.2.3. Can you try it with 3.2.3?
 
 -- 
 	Falk


^ permalink raw reply	[flat|nested] 3+ messages in thread

* optimization/10562: Code segment optimization incorrectly disappeared with -O2 option
@ 2003-04-30  6:16 fleming.feng
  0 siblings, 0 replies; 3+ messages in thread
From: fleming.feng @ 2003-04-30  6:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: eddie.dong


>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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-04-30 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-30 13:55 optimization/10562: Code segment optimization incorrectly disappeared with -O2 option bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-04-30 10:56 Falk Hueffner
2003-04-30  6:16 fleming.feng

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).