From: Paolo Bonzini <pbonzini@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-trivial@nongnu.org,
Thomas Schwinge <thomas@codesourcery.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH] fpu: Simplify floatx80ToCommonNaN function.
Date: Fri, 31 May 2013 14:24:25 +0200 [thread overview]
Message-ID: <51A89679.5020805@redhat.com> (raw)
In-Reply-To: <51A89273.8010400@msgid.tls.msk.ru>
Il 31/05/2013 14:07, Michael Tokarev ha scritto:
> 31.05.2013 13:39, Thomas Schwinge wrote:
>> Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
>> ---
>> fpu/softfloat-specialize.h | 15 +++++++--------
>> 1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git fpu/softfloat-specialize.h fpu/softfloat-specialize.h
>> index 518f694..83add1a 100644
>> --- fpu/softfloat-specialize.h
>> +++ fpu/softfloat-specialize.h
>> @@ -934,15 +934,14 @@ static commonNaNT floatx80ToCommonNaN( floatx80 a STATUS_PARAM)
>> commonNaNT z;
>>
>> if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR);
>> - if ( a.low >> 63 ) {
>> - z.sign = a.high >> 15;
>> - z.low = 0;
>> - z.high = a.low << 1;
>> - } else {
>> - z.sign = floatx80_default_nan_high >> 15;
>> - z.low = 0;
>> - z.high = floatx80_default_nan_low << 1;
>> + /* Replace a Pseudo NaN with a default NaN. */
>> + if (!(a.low >> 63)) {
>> + a.low = floatx80_default_nan_low;
>> + a.high = floatx80_default_nan_high;
>> }
>> + z.sign = a.high >> 15;
>> + z.low = 0;
>> + z.high = a.low << 1;
>> return z;
>> }
>
> Hmm. And where's the simplification? Here's context diff for the same:
>
> *** fpu/softfloat-specialize.h.orig 2013-05-31 16:02:51.614710351 +0400
> --- fpu/softfloat-specialize.h 2013-05-31 16:02:59.838820308 +0400
> ***************
> *** 936,946 ****
> if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR);
> ! if ( a.low >> 63 ) {
> ! z.sign = a.high >> 15;
> ! z.low = 0;
> ! z.high = a.low << 1;
> ! } else {
> ! z.sign = floatx80_default_nan_high >> 15;
> ! z.low = 0;
> ! z.high = floatx80_default_nan_low << 1;
> }
> return z;
> --- 936,945 ----
> if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR);
> ! /* Replace a Pseudo NaN with a default NaN. */
> ! if (!(a.low >> 63)) {
> ! a.low = floatx80_default_nan_low;
> ! a.high = floatx80_default_nan_high;
> }
> + z.sign = a.high >> 15;
> + z.low = 0;
> + z.high = a.low << 1;
> return z;
>
>
> Yes, your version is 3 lines shorter, because it
> does not have extra else{} (2 lines) and the
> remaining if() construct is one line shorter too,
> due to moving z.low=0 construct into common place.
>
> But I don't think your version is more readable, --
> before it was easy to understand what is going on,
> we had two easy case with all right stuff done for
> each case. Now we do some preparation before, so
> the common case works.
>
> Generated code should be about the same anyway, but
> to me (IMHO!), original code is a bit more readable.
I agree. It's also not trivial.
Paolo
next prev parent reply other threads:[~2013-05-31 12:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 9:39 [Qemu-trivial] [PATCH] fpu: Simplify floatx80ToCommonNaN function Thomas Schwinge
2013-05-31 12:07 ` Michael Tokarev
2013-05-31 12:24 ` Paolo Bonzini [this message]
2013-05-31 12:34 ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2013-05-31 13:01 ` Thomas Schwinge
2013-05-31 14:45 ` Peter Maydell
2013-06-03 11:05 ` Thomas Schwinge
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=51A89679.5020805@redhat.com \
--to=pbonzini@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=thomas@codesourcery.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;
as well as URLs for NNTP newsgroup(s).