public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Thorsten Otto <admin@tho-otto.de>
To: linux-m68k@vger.kernel.org, Michael Schmitz <schmitzmic@gmail.com>
Subject: Re: Software FPU emulation in linux kernel
Date: Tue, 04 Mar 2025 06:47:40 +0100	[thread overview]
Message-ID: <6144250.UjTJXf6HLC@earendil> (raw)
In-Reply-To: <091d25fa-6a79-4685-a920-075611e79626@gmail.com>

> 
> both operands are checked for infinity
> first.

Not really. The code reads

/* Handle infinities */
	if (IS_INF(dest)) {
		if (IS_ZERO(src))
			fp_set_nan(dest);
		return dest;
	}

So the src argument is checked for ZERO first.

Similar in the implementation of fgetman:

	if (IS_ZERO(dest))
		return dest;

	if (IS_INF(dest))
		return dest;



> I cannot locate the specific assembly function you mention
> (fp_long_ext2ext). Can you post code or disassembly to illustrate the
> problem?

A sorry, i meant fp_conv_ext2ext. It is called by the fp_normalize_ext() macro 
in fp_emu.h, which in turn is called by fp_monadic_check/fp_dyadic_check.

> That might be a genuine error in the sqrt algorithm there - can't see
> how it does arise though.

I think this is caused by

	dest->exp += (exp - 0x3FFF) / 2;

`exp` here is the original exponent of the source, and if that is < 1.0, the 
expression `exp - 0x3FFF` will become negative, but the division truncates it 
towards zero. IMHO using `>> 1` should fix that.

>  You may
> have to look elsewhere for a feature complete FPU emulation (does netbsd
> have that?).

Yes, NetBSD has something similar, and it seems to be almost complete, 
including all the trigonometric functions. However they do everything in C, 
including all the <ea> calculations. The linux version seems to be much better 
in this regard.




  parent reply	other threads:[~2025-03-04  5:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 16:22 Software FPU emulation in linux kernel Thorsten Otto
2025-03-03 22:10 ` Brad Boyer
2025-03-04  5:24   ` Thorsten Otto
2025-03-04  5:48     ` Brad Boyer
2025-03-03 23:38 ` Michael Schmitz
2025-03-04  4:44   ` Finn Thain
2025-03-04  5:47   ` Thorsten Otto [this message]
2025-03-06 15:24 ` Thorsten Otto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6144250.UjTJXf6HLC@earendil \
    --to=admin@tho-otto.de \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox