This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: optimization/8794: optimization improperly eliminates certain expressions


On Tue, Dec 03, 2002 at 02:29:05PM -0000, pageexec@freemail.hu wrote:
> >Number:         8794
> >Category:       optimization
> >Synopsis:       optimization improperly eliminates certain expressions
> >Release:        gcc 3.2.1

Confirmed on i686. The orignal example works ok on sparc but a slightly
simplified example produces bad code on sparc with 3.2.1 and 3.3:

------------- cut ------------------
unsigned int addr;
void f (void)
{
	addr = (1024 & (1024UL - (addr & 1023UL)));
}
------------- cut ------------------

Is compiled into:

------------- cut ------------------
	.file	"8794.c"
	.section	".text"
	.align 4
	.global f
	.type	f,#function
	.proc	020
f:
	!#PROLOGUE# 0
	!#PROLOGUE# 1
	mov	1024, %o1
	sethi	%hi(addr), %o0
	retl
	st	%o1, [%o0+%lo(addr)]
.LLfe1:
	.size	f,.LLfe1-f
	.common	addr,4,4
	.ident	"GCC: (GNU) 3.2.1 20021111 (prerelease)"
------------- cut ------------------

Which is clearly wrong. The necessary instructions are elimiated by
between 8794.c.15.life and 8794.c.16.combine.

      regards   Christian

-- 
THAT'S ALL FOLKS!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]