[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [ID 20020504.002] 1 == 1 but 0 != 0



On Sat, May 04, 2002 at 11:08:43PM -0500, Ben Winslow wrote:
> This turned out to be a problem with CONFIG_FPE_FASTFPE
> (CONFIG_FPE_NWFPE works fine.)  Thanks to everyone who provided insight
> into the problem.

On Mon, Jun 17, 2002 at 11:32:21AM -0700, Tony Lindgren wrote:
> * mallum <breakfast@10.am> [020614 07:13]:
> > I too have this exact same problem on a CATS machine running debian
> > unstable ( kernel 2.4.18-rmk6 ).
> > 
> > Is the only fix to link to debug-perl ?
> > 
> >   -- Matthew
> 
> Hi,
> 
> Well, I finally got around to verifying that this is caused by the Fast
> Floating Point Emulator. So the real solution is to use the Netwinder
> Floating Point Emulator. Symlinking perl to debug-perl seems to be a
> work around with the Fast Floating Point Emulator.
> 
> In any case, it's weird how the FastFPE works with debug-perl and not
> with perl...
> 
> Tony


I wasn't aware of anyone getting this down to a test case.
The problem seems to be saving a floating point register containing 0 to
memory, and then reloading it. The same binaries give:

nick@Bagpuss [test]$ ./is_zero 
1
nick@Bagpuss [test]$ ./is_one  
1
nick@Bagpuss [test]$ dmesg | grep -i Floating
NetWinder Floating Point Emulator V0.95 (c) 1998-1999 Rebel.com

nick@Bagpuss [test]$ ./is_zero 
0
nick@Bagpuss [test]$ ./is_one  
1
nick@Bagpuss [test]$ dmesg | grep -i Floating
Fast Floating Point Emulator V0.9 (c) Peter Teichmann.

If I take the lfmfd out from this then it all works as expected on FastFPE

	mvfd	f1, #0
	sfmfd	f1, 1, [sp]!
	lfmfd	f1, 1, [sp]!
	mvfd	f0, #0
	cmf	f0, f1

nick@Bagpuss [test]$ ./is_zero_noload 
1

Attached are source for is_zero and is_one

Nicholas Clark
-- 
Even better than the real thing:	http://nms-cgi.sourceforge.net/
@ Generated by gcc 2.95.4 20010319 (Debian prerelease) for ARM/elf
	.file	"temp.c"
gcc2_compiled.:
.section	.rodata
	.align	2
.LC0:
	.ascii	"%d\012\000"
.text
	.align	2
	.global	main
	.type	 main,function
main:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, current_function_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {r4, fp, ip, lr, pc}
	sub	fp, ip, #4
	mvfd	f1, #0
	sfmfd	f1, 1, [sp]!
	lfmfd	f1, 1, [sp]!
	mvfd	f0, #0
	cmf	f0, f1
	movne	r1, #0
	moveq	r1, #1
	ldr	r0, .L149
	bl	printf
.L150:
	.align	2
.L149:
	.word	.LC0
.L148:
        mov     r0, #0
	ldmea	fp, {r4, fp, sp, pc}
.Lfe2:
	.size	 Perl_pp_eq,.Lfe2-Perl_pp_eq
	.ident	"GCC: (GNU) 2.95.4 20010319 (Debian prerelease)"
@ Generated by gcc 2.95.4 20010319 (Debian prerelease) for ARM/elf
	.file	"temp.c"
gcc2_compiled.:
.section	.rodata
	.align	2
.LC0:
	.ascii	"%d\012\000"
.text
	.align	2
	.global	main
	.type	 main,function
main:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, current_function_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {r4, fp, ip, lr, pc}
	sub	fp, ip, #4
	mvfd	f1, #1
	sfmfd	f1, 1, [sp]!
	lfmfd	f1, 1, [sp]!
	mvfd	f0, #1
	cmf	f0, f1
	movne	r1, #0
	moveq	r1, #1
	ldr	r0, .L149
	bl	printf
.L150:
	.align	2
.L149:
	.word	.LC0
.L148:
        mov     r0, #0
	ldmea	fp, {r4, fp, sp, pc}
.Lfe2:
	.size	 Perl_pp_eq,.Lfe2-Perl_pp_eq
	.ident	"GCC: (GNU) 2.95.4 20010319 (Debian prerelease)"

Reply to: