Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-03 Thread J. Gareth Moreton
It's already there. I deleted the faulty one and included a new copy with the fix.  It's probably not the best approach, but I didn't want a long list of patches like I've ended up with before. Gareth aka. Kit On Thu 03/05/18 06:56 , "Sven Barth" pascaldra...@googlemail.com sent: J. Gareth Mo

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-02 Thread Sven Barth via fpc-devel
J. Gareth Moreton schrieb am Do., 3. Mai 2018, 04:55: > Tests complete! It turns out that I was using SetExceptionMask wrong and > subtracting rather than adding exInvalidOp. > > When exceptions are disabled, this new Frac function returns NaN when you > pass in plus or minus infinity. This is c

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-02 Thread J. Gareth Moreton
Tests complete! It turns out that I was using SetExceptionMask wrong and subtracting rather than adding exInvalidOp. When exceptions are disabled, this new Frac function returns NaN when you pass in plus or minus infinity.  This is consistent with the specification as listed in Chapter 11, Secti

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-02 Thread J. Gareth Moreton
I'll keep working on it though, because it seems that some routines may return placeholder values if exceptions are masked. Gareth aka. Kit On Thu 03/05/18 02:35 , "J. Gareth Moreton" gar...@moreton-family.com sent: Hi guys, I've been having difficulties disabling floating-point and SSE ex

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-02 Thread J. Gareth Moreton
Hi guys, I've been having difficulties disabling floating-point and SSE exceptions. Either the exceptions are still raised, or an exception is raised elsewhere... sometimes within the function, and in one instance, in the WriteLn routine!  Does anyone have any advice as to how to get around this

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-02 Thread Sven Barth via fpc-devel
J. Gareth Moreton schrieb am Mi., 2. Mai 2018, 11:10: > > > > > On Wed 02/05/18 06:55 , Sven Barth pascaldra...@googlemail.com sent: > > ... > Thank you for the work so far. Does it also work correctly when exceptions > are disabled? > > Regards, > Sven > > > I confess I haven't tested that - I k

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-02 Thread J. Gareth Moreton
On Wed 02/05/18 06:55 , Sven Barth pascaldra...@googlemail.com sent: ... Thank you for the work so far. Does it also work correctly when exceptions are disabled? Regards, Sven I confess I haven't tested that - I know it involves setting the FPU control word, but what should I expect? Gar

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-01 Thread Sven Barth via fpc-devel
J. Gareth Moreton schrieb am Di., 1. Mai 2018, 23:39: > It turns out I did over-engineer the solution somewhat - this version is > far more efficient, honours NaNs and triggers SIGFPE if infinity is passed > in (subsd triggers it), hence there are no regressions. > > > > function fpc_frac_re

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-01 Thread J. Gareth Moreton
It turns out I did over-engineer the solution somewhat - this version is far more efficient, honours NaNs and triggers SIGFPE if infinity is passed in (subsd triggers it), hence there are no regressions. function fpc_frac_real(d: ValReal): ValReal; compilerproc; assembler; nostackframe;

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-01 Thread J. Gareth Moreton
On Tue 01/05/18 20:11 , Jonas Maebe jo...@freepascal.org sent: > On 01/05/18 21:06, J. Gareth Moreton wrote: > > > I asked about the rules regarding > > > infinities, but going by what happens with > > > the old floating-point stack, an exception > > > is raised, > > > > The code also

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-01 Thread Jonas Maebe
On 01/05/18 21:06, J. Gareth Moreton wrote: I asked about the rules regarding infinities, but going by what happens with the old floating-point stack, an exception is raised, The code also has to work if exceptions are disabled. Jonas ___ fpc-devel

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-01 Thread J. Gareth Moreton
As Sven pointed out, there are still faults in our functions in that they don't honour NaNs. It's an easy enough fix, but will just need an extra bit of code. I asked about the rules regarding infinities, but going by what happens with the old floating-point stack, an exception is raised, so

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-05-01 Thread J. Gareth Moreton
I reopened the bug ticket to attach a patch with the new function. It also contains some code for "Int" that passes through the input unchanged if its magnitude is greater than 2^52 (at this point, the precision means it can't have a fractional component).  I've set it to "feedback" currently so S

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-04-29 Thread J. Gareth Moreton
Hi Florian.  Thorsten and I got down to a fairly optimised version of Frac, in both speed and size: function Frac(const X: ValReal): ValReal; assembler; nostackframe; asm   movq  rax,  xmm0   shr   rax,  48   and   ax,   $7FF0   cmp   ax,   $4330   jge   @@zero

Re: [fpc-devel] Broken frac functionin FPC3.1.1 / Windows x86_64

2018-04-29 Thread J. Gareth Moreton
That's great to hear! Glad to help. For functions with no stack frame, the compiler simply puts RET at the very end of the routine and is all that's needed. For functions with a stack frame, either LEAVE or MOV RSP, RBP; POP RBP must precede it. The optional parameter after RET is the number