[BUG][GCC] *Serious* optimization bug: Any gcc specialists out there?

Chris Wright caw at cs.mu.oz.au
Mon Aug 7 02:40:30 UTC 2000


"Richard A. O'Keefe" wrote:

[? The Craft of Smalltalk on its way?? ;-)]


> 
> Instead of just
>         gcc -O testDoubles.c -lm
>         gcc    testDoubles.c -lm
> how about
>         gcc -S -O testDoubles.c
> and     gcc -S    testDoubles.c
> from someone with a Linux box so that we know what the code is?


ok. This is about the level at which I can make a contribution (do what
I'm told by an expert!)

here's bug.c:

#include <stdio.h>
#include <math.h>

testDoubles () {
	double arg1 = 1e20;
	printf("\nsin(arg1): %d\n", sin(arg1));
}

int main() {
	testDoubles(); 
	return 0;
}


and here's

bug.s from
gcc -S -O bug.c

	.file	"bug.c"
	.version	"01.01"
gcc2_compiled.:
.section	.rodata
.LC47:
	.string	"\nsin(arg1): %d\n"
	.align 8
.LC46:
	.long 0x78b58c40,0x4415af1d
.text
	.align 4
.globl testDoubles
	.type	 testDoubles, at function
testDoubles:
	pushl %ebp
	movl %esp,%ebp
	fldl .LC46
#APP
	fsin
#NO_APP
	subl $8,%esp
	fstpl (%esp)
	pushl $.LC47
	call printf
	leave
	ret
.Lfe1:
	.size	 testDoubles,.Lfe1-testDoubles
	.align 4
.globl main
	.type	 main, at function
main:
	pushl %ebp
	movl %esp,%ebp
	call testDoubles
	xorl %eax,%eax
	leave
	ret
.Lfe2:
	.size	 main,.Lfe2-main
	.ident	"GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"



and here's bug.s from
gcc -S testDoubles.c

	.file	"bug.c"
	.version	"01.01"
gcc2_compiled.:
.section	.rodata
.LC0:
	.string	"\nsin(arg1): %d\n"
.text
	.align 4
.globl testDoubles
	.type	 testDoubles, at function
testDoubles:
	pushl %ebp
	movl %esp,%ebp
	subl $8,%esp
	movl $2025163840,-8(%ebp)
	movl $1142271773,-4(%ebp)
	fldl -8(%ebp)
	subl $8,%esp
	fstpl (%esp)
	call sin
	addl $8,%esp
	subl $8,%esp
	fstpl (%esp)
	pushl $.LC0
	call printf
	addl $12,%esp
.L1:
	leave
	ret
.Lfe1:
	.size	 testDoubles,.Lfe1-testDoubles
	.align 4
.globl main
	.type	 main, at function
main:
	pushl %ebp
	movl %esp,%ebp
	call testDoubles
	xorl %eax,%eax
	jmp .L2
	.p2align 4,,7
.L2:
	leave
	ret
.Lfe2:
	.size	 main,.Lfe2-main
	.ident	"GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"


and uname -a :
Linux icu-0 2.2.14-12 #1 Tue Apr 25 12:31:52 EDT 2000 i686 unknown

I hope this helps!

cheers

chris

-- 
Dr. Chris Wright
Deputy Director, Intensive Care Unit
Monash Medical Centre
Clayton, VIC AUSTRALIA





More information about the Squeak-dev mailing list