A bug in div64.s
fred.liu at motorola.com
Mon Sep 12 20:05:13 EST 2005
Thank you very much. Your code is really cool.
From: Paul Mackerras [mailto:paulus at samba.org]
Sent: Monday, September 12, 2005 4:26 PM
To: Liu Fred-a18596
Cc: linuxppc-dev at ozlabs.org
Subject: Re: A bug in div64.s
Liu Fred-a18596 writes:
> I found there was a bug in arch/ppc/lib/div64.s.
> The original div64_32() function would produce a zero divide
> exception in case of div64_32(0x100000000, 0xFFFFFFFF).
Thanks for pointing this out.
> Here is the bug-fixed new div64_32()function.
A patch would have been more helpful, so we could see immediately what
you have changed. Also, notes (or outlook or whatever mail program
you are using) has completely munged all the spacing of the code you
Anyway, I have some comments on your proposed fix:
> addc. r9,r4,r10 # rounding up (so the estimate cannot
I understand that the add that I had here can overflow in the case you
pointed out, so we need to preserve the carry. But why did you use
"addc." rather than "addc" ?
> mfxer r12 #
> rlwinm. r12, r12, 3, 31, 31 # XER[CA]
> cmpwi r12, 1 # carry ?
> bne 5f
> ori r9, r9, 0x1 # carry !
I think just "addze r9,r9" would do instead of these 5 instructions,
More information about the Linuxppc-dev