www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1998/09/08/16:13:32

X-pop3-spooler: POP3MAIL 2.1.0 b 4 980420 -bs-
Message-Id: <3.0.32.19980908180857.009d99b0@xs4all.nl>
X-Sender: diep AT xs4all DOT nl
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Tue, 08 Sep 1998 18:09:05 +0000
To: strasbur AT chkw386 DOT ch DOT pwr DOT wroc DOT pl (Krzysztof Strasburger),
beastium-list AT Desk DOT nl
From: Vincent Diepeveen <diep AT xs4all DOT nl>
Subject: Re: -O1 -ffast-math bug on Pentium Pro
Mime-Version: 1.0
Sender: Marc Lehmann <pcg AT goof DOT com>
Status: RO
X-Status: A
Lines: 133

At 08:10 AM 9/8/98, Krzysztof Strasburger wrote:
>I reduced the code size needed to reproduce the bug.
>Compiled with -mpentiumpro -O1 -malign-double -malign-jumps=0 -malign-loops=0
>-malign-functions=0 -fno-exceptions -traditional -ffast-math.
>main() calls fmbug(), should print p=1. Prints p=0.
>I hope this will help to fix the bug.
>Krzysztof
>
>int main()
>{
>    double p;
>    extern int fmbug();
>    p = 1.;
>    fmbug(&p);
>    printf("p=%f\n",p);
>    return 0;
>}
>
>The fmbug() function is now very small.
>
>int fmbug(param)
>double *param;
>{
>    double h1;
>
>    h1 = -(*param);
>    if (abs(*param) < 1e-10 || h1 > -1e-10) {
>	*param = 0.;
>    }
>    return 0;
>}

This is a rather old way of unprototyped programming.

Does the bug also show up when using:

(above main the prototype)
  'int fmbug(double *);'

defining function as: 
  'int fmbug(double *param) {'

Or does this not matter for the bug?

>Here is the asembler output of pgcc-1.1a (fmbug, with fast-math)

Who can read such unreadable assembler outputs?

>	.file	"fmbug.c"
>	.version	"01.01"
>gcc2_compiled.:
>.text
>.globl fmbug
>	.type	 fmbug,@function
>fmbug:
>	pushl %ebp
>	movl %esp,%ebp
>	subl $24,%esp
>	movl 8(%ebp),%ecx
>	fldl (%ecx)
>	fld %st(0)
>	fchs
>	fxch %st(1)
>	fnstcw -4(%ebp)
>	movl -4(%ebp),%eax
>	movb $12,%ah
>	movl %eax,-16(%ebp)
>	fldcw -16(%ebp)
>	fistpl -20(%ebp)
>	fldcw -4(%ebp)
>	movl -20(%ebp),%edx
>	sarl $31,%edx
>	movl -20(%ebp),%eax
>	xorl %edx,%eax
>	subl %edx,%eax
>	fldl .LC0
>	pushl %eax
>	ficompl (%esp)
>	addl $4,%esp
>	fnstsw %ax
>	seta %al
>	movzbl %al,%edx
>	fldl .LC1
>	fcompp
>	fnstsw %ax
>	setb %al
>	movb %al,-20(%ebp)
>	movzbl -20(%ebp),%eax
>	orl %eax,%edx
>	je .L2
>	movl $0,(%ecx)
>	movl $0,4(%ecx)
>.L2:
>	xorl %eax,%eax
>	movl %ebp,%esp
>	popl %ebp
>	ret
>.Lfe1:
>	.size	 fmbug,.Lfe1-fmbug
>.section	.rodata
>	.align 8
>.LC0:
>	.long 0xd9d7bdbb,0x3ddb7cdf
>	.align 8
>.LC1:
>	.long 0xd9d7bdbb,0xbddb7cdf
>.text
>	.ident	"GCC: (GNU) pgcc-2.91.57 19980901 (egcs-1.1 release)"
>
>and the difference 
>
>--- fmbug.s.fm	Tue Sep  8 07:37:50 1998
>+++ fmbug.s.nfm	Tue Sep  8 07:37:55 1998
>@@ -30,12 +30,15 @@
> 	ficompl (%esp)
> 	addl $4,%esp
> 	fnstsw %ax
>-	seta %al
>+	andb $69,%ah
>+	sete %al
> 	movzbl %al,%edx
> 	fldl .LC1
> 	fcompp
> 	fnstsw %ax
>-	setb %al
>+	andb $69,%ah
>+	cmpb $1,%ah
>+	sete %al
> 	movb %al,-20(%ebp)
> 	movzbl -20(%ebp),%eax
> 	orl %eax,%edx
>
>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019