|
Message-ID: <20120315053011.GK5728@port70.net> Date: Thu, 15 Mar 2012 06:30:11 +0100 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: correctly rounded sqrt * Rich Felker <dalias@...ifal.cx> [2012-03-15 01:07:48 -0400]: > Here's the asm version based on fpu status word. I'm not sure if it's > safe for non-default rounding modes but otherwise it should be > correct. up,down,zero rounding should be ok we change ..xxx|10000.. into one of ..xxx|10100.. ..xxx|01100.. and both of them round the same way with ru,rd,rz > .global sqrt > .type sqrt,@function > sqrt: fldl 4(%esp) > fsqrt > fstsw %ax > sub $12,%esp > fld %st(0) > fstpt (%esp) > mov (%esp),%ecx > and $0x7ff,%ecx > cmp $0x400,%ecx > jnz 1f > and $0x200,%eax > sub $0x100,%eax > sub %eax,(%esp) here you modify the return value even if it was nan eg c99 F.9 recommends no nan modifications if ((y & 0x7fff<<64) == 0x7fff<<64) ... > fstp %st(0) > fldt (%esp) > 1: add $12,%esp > fstpl 4(%esp) > fldl 4(%esp) > ret
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.