From: "Alex Bennée" <alex.bennee@linaro.org>
To: Aleksandar Markovic <amarkovic@wavecomp.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Mateja Marjanovic <mateja.marjanovic@rt-rk.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"aurelien@aurel32.net" <aurelien@aurel32.net>,
Aleksandar Rikalo <arikalo@wavecomp.com>
Subject: Re: [Qemu-devel] [PATCH] target/mips: Fix minor bug in FPU
Date: Mon, 11 Mar 2019 15:18:16 +0000 [thread overview]
Message-ID: <87ef7d5tjb.fsf@zen.linaroharston> (raw)
In-Reply-To: <BN6PR2201MB12515708748670C8F930B088C6480@BN6PR2201MB1251.namprd22.prod.outlook.com>
Aleksandar Markovic <amarkovic@wavecomp.com> writes:
>> From: Alex Bennée <alex.bennee@linaro.org>
>>
>> > Aleksandar Markovic <amarkovic@wavecomp.com> writes:
>>
>> >> From: Peter Maydell <peter.maydell@linaro.org>
>> >> Subject: Re: [PATCH] target/mips: Fix minor bug in FPU
>> >>
>> >> On Mon, 11 Mar 2019 at 11:52, Aleksandar Markovic
>> >> <amarkovic@wavecomp.com> wrote:
>> >> >
>> >> > > From: Mateja Marjanovic <mateja.marjanovic@rt-rk.com>
>> >> > > Subject: [PATCH] target/mips: Fix minor bug in FPU
>> >> > >
>> >> > > Wrong type of NaN was generated by maddf and msubf insturctions
>> >> > > when the arguments were inf, zero, nan or zero, inf, nan
>> >> > > respectively.
>> >> >
>> >> > I did the applicable tests on both pre-NaN2008 and NaN2008 MIPS hardware,
>> >> > and compared results with QEMu emulations. The underlying reason for this
>> >> > patch is correct, but, as Alex also pointed out, it needs some improvements.
>> >> > However, the softfreeze being so close, I am going to amend the patch while
>> >> > creating the pull request. No respin needed. All in all:
>> >>
>> >> Since this is a bug fix, there is no requirement that it goes in
>> >> before softfreeze, FWIW -- pretty much any bug fix is OK for
>> >> rc1, and a focused bugfix like this one that doesn't affect
>> >> other guest architectures would be ok in rc2 as well.
>> >>
>> >
>> > Thanks, Peter, for the clarification!
>> >
>> > In this case, I think, the most natural would be to wait for the
>> > submitter to submit the v2.
>> >
>> > The reference to the documentation that Alex rightfully asked for
>> > is this:
>> >
>> > "MIPS Architecture for Programmers Volume IV-j: The MIPS32
>> > SIMD Architecture Module", Revision 1.12, February 3, 2016
>> >
>> > The key sentence is on page 53:
>> >
>> > "If the destination format is floating-point, all NaN propagating
>> > operations with one NaN operand produce a NaN with the
>> > payload of the input NaN."
>>
>> Hmm doesn't that fail for:
>>
>> Inf * Zero + !NaN?
>>
>> Should the check be:
>>
>> if (infzero) {
>> float_raise(float_flag_invalid, status);
>> if (is_nan(c_cls)) {
>> return 2;
>> }
>> return 3;
>> }
>>
>> ?
>>
>> If either a or b is a NaN we fall through to the NaN selection rules
>> bellow preferring SNaN over QNaN.
>>
>
> Alex,
>
> I'll doublecheck, but I think "infzero" here is a misnomer.
>
> The variable/argument "infzero" actually denotes the cases:
>
> - "Inf * Zero +/- NaN"
> - "Inf * Zero +/- NaN"
> - "Zero * Inf +/- NaN"
> - "Zero * Inf +/- NaN"
>
> "Inf * Zero +/- !NaN (let's say, normal fp)" is handled
> somewhere else.
Ahh my mistake, infzero only cares about a and b:
bool inf_zero = ((1 << a.cls) | (1 << b.cls)) ==
((1 << float_class_inf) | (1 << float_class_zero));
but is wrapped in:
if (is_nan(a.cls) || is_nan(b.cls) || is_nan(c.cls)) {
return pick_nan_muladd(a, b, c, inf_zero, s);
}
Which when infzero is true implies c has to be the NaN...
>
> Therefore, "infzero" should be rather called "infzeronan".
> This is from what I remember, but I will reanalyse the
> relevant softfloat code one more time.
No need. I overthought it ;-)
>
> Regards,
> Aleksandar
>
>> >
>> > There are other details in surrounding paragraphs. The document
>> > is for SIMD (MSA) ASE, but both the SIMD and FPU NaN2008
>> > floating point instruction should follow the same rules. I could't
>> > find a separate document on FPU instructions.
>> >
>> > The problem with the current implementation of 0*inf+nan is that
>> > it returns the default NaN (all zeroes in the payload segment),
>> > whereas the documentation says the payload should be from
>> > the input NaN. The behavior specified in the documentation is
>> > confirmed also with tests on hardware.
>> >
>> > Sincerely,
>> > Aleksandar
>>
>>
>> --
>> Alex Bennée
--
Alex Bennée
prev parent reply other threads:[~2019-03-11 15:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 17:10 [Qemu-devel] [PATCH] target/mips: Fix minor bug in FPU Mateja Marjanovic
2019-03-07 17:10 ` Mateja Marjanovic
2019-03-07 17:32 ` Alex Bennée
2019-03-07 17:43 ` Aleksandar Markovic
2019-03-07 18:25 ` Alex Bennée
2019-03-11 11:52 ` Aleksandar Markovic
2019-03-11 12:50 ` Peter Maydell
2019-03-11 13:58 ` Aleksandar Markovic
2019-03-11 14:18 ` Alex Bennée
2019-03-11 14:35 ` Aleksandar Markovic
2019-03-11 14:48 ` Peter Maydell
2019-03-11 15:18 ` Alex Bennée [this message]
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=87ef7d5tjb.fsf@zen.linaroharston \
--to=alex.bennee@linaro.org \
--cc=amarkovic@wavecomp.com \
--cc=arikalo@wavecomp.com \
--cc=aurelien@aurel32.net \
--cc=mateja.marjanovic@rt-rk.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.