qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: peter.maydell@linaro.org, danielhb413@gmail.com, groug@kaod.org,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org,
	"Matheus K. Ferst" <matheus.ferst@eldorado.org.br>,
	aurelien@aurel32.net, david@gibson.dropbear.id.au
Subject: Re: [RFC PATCH] target/ppc: do not silence snan in xscvspdpn
Date: Wed, 15 Dec 2021 15:55:08 +0000	[thread overview]
Message-ID: <87ee6dg8in.fsf@linaro.org> (raw)
In-Reply-To: <02d2318e-f857-60d2-27f8-da7992193008@amsat.org>


Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 12/13/21 21:15, Matheus K. Ferst wrote:
>> On 13/12/2021 09:36, Philippe Mathieu-Daudé wrote:
>>> On 12/13/21 13:13, matheus.ferst@eldorado.org.br wrote:
>>>> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
>>>>
>>>> The non-signalling versions of VSX scalar convert to shorter/longer
>>>> precision insns doesn't silence SNaNs in the hardware. We are currently
>>>> honoring this behavior in xscvdpspn, since helper_xscvdpspn handles the
>>>> conversion with extracts/deposits/etc. OTOH, xscvspdpn uses
>>>> float32_to_float64 that calls parts_float_to_float, which uses
>>>> parts_return_nan that finally calls parts_silence_nan if the input is an
>>>> SNaN.
>>>>
>>>> To address this problem, this patch adds a new float_status flag
>>>> (return_snan) to avoid the call to parts_silence_nan in the
>>>> float_class_snan case of parts_return_nan.
>>>>
>>>> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
>>>> ---
>>>> This behavior was observed in a Power9 and can be reproduced with the
>>>> following code:
>>>>
>>>> int main(void)
>>>> {
>>>>      __uint128_t t, b = 0x7f80000200000000;
>>>>
>>>>      asm("xscvspdpn %x0, %x1\n\t"
>>>>          : "=wa" (t)
>>>>          : "wa" (b << 64));
>>>>      printf("0x%016" PRIx64 "%016" PRIx64 "\n",
>>>>             (uint64_t)(t >> 64), (uint64_t)t);
>>>>
>>>>      b = 0x7ff0000000000002;
>>>>      asm("xscvdpspn %x0, %x1\n\t"
>>>>          : "=wa" (t)
>>>>          : "wa" (b << 64));
>>>>      printf("0x%016" PRIx64 "%016" PRIx64 "\n",
>>>>             (uint64_t)(t >> 64), (uint64_t)t);
>>>>
>>>>      return 0;
>>>> }
>>>
>>> Why not add this test in tests/tcg/ppc64le/ ?
>> 
>> I'll add it in v2. Is it ok to use __uint128_t in tests?
>
> What about:
>
>   int main(void)
>   {
>   #ifndef __SIZEOF_INT128__
>       printf("uint128_t not available, skipping...\n");
>   #else
>       ...
>   #endif
>       return 0;
>   }

We have a tests/tcg/configure.sh which does feature tests although it is
mainly testing for the presence of compiler target flags.  We do this
because while the docker compilers are all pretty modern the user might
be using their own cross compiler.

I'm generally not keen on the tests silently skipping because it gives a
false impression things have been tested. If it is possible to avoid
INT128 shenanigans to load the values into the inline assembler lets do
that, otherwise lets feature test and ifdef a skip-test in the makefile.

-- 
Alex Bennée


  reply	other threads:[~2021-12-15 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 12:13 [RFC PATCH] target/ppc: do not silence snan in xscvspdpn matheus.ferst
2021-12-13 12:36 ` Philippe Mathieu-Daudé
2021-12-13 20:15   ` Matheus K. Ferst
2021-12-13 22:19     ` Philippe Mathieu-Daudé
2021-12-15 15:55       ` Alex Bennée [this message]
2021-12-15 20:01         ` Matheus K. Ferst
2021-12-13 15:46 ` Richard Henderson
2021-12-13 20:15   ` Matheus K. Ferst

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=87ee6dg8in.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=f4bug@amsat.org \
    --cc=groug@kaod.org \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).