From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: philmd@redhat.com, Thomas Huth <thuth@redhat.com>,
alex.bennee@linaro.org
Subject: [PATCH v4 1/6] fpu/softfloat: Silence 'bitwise negation of boolean expression' warning
Date: Wed, 17 Jun 2020 13:13:04 -0700 [thread overview]
Message-ID: <20200617201309.1640952-2-richard.henderson@linaro.org> (raw)
In-Reply-To: <20200617201309.1640952-1-richard.henderson@linaro.org>
From: Philippe Mathieu-Daudé <philmd@redhat.com>
When building with clang version 10.0.0-4ubuntu1, we get:
CC lm32-softmmu/fpu/softfloat.o
fpu/softfloat.c:3365:13: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fpu/softfloat.c:3423:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
fpu/softfloat.c:4273:18: error: bitwise negation of a boolean expression; did you mean logical negation? [-Werror,-Wbool-operation]
zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix by rewriting the fishy bitwise AND of two bools as an int.
Suggested-by: Eric Blake <eblake@redhat.com>
Buglink: https://bugs.launchpad.net/bugs/1881004
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200528155420.9802-1-philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 6c8f2d597a..5e9746c287 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -3362,7 +3362,9 @@ static int32_t roundAndPackInt32(bool zSign, uint64_t absZ,
}
roundBits = absZ & 0x7F;
absZ = ( absZ + roundIncrement )>>7;
- absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
+ if (!(roundBits ^ 0x40) && roundNearestEven) {
+ absZ &= ~1;
+ }
z = absZ;
if ( zSign ) z = - z;
if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
@@ -3420,7 +3422,9 @@ static int64_t roundAndPackInt64(bool zSign, uint64_t absZ0, uint64_t absZ1,
if ( increment ) {
++absZ0;
if ( absZ0 == 0 ) goto overflow;
- absZ0 &= ~ ( ( (uint64_t) ( absZ1<<1 ) == 0 ) & roundNearestEven );
+ if (!(absZ1 << 1) && roundNearestEven) {
+ absZ0 &= ~1;
+ }
}
z = absZ0;
if ( zSign ) z = - z;
@@ -3480,7 +3484,9 @@ static int64_t roundAndPackUint64(bool zSign, uint64_t absZ0,
float_raise(float_flag_invalid, status);
return UINT64_MAX;
}
- absZ0 &= ~(((uint64_t)(absZ1<<1) == 0) & roundNearestEven);
+ if (!(absZ1 << 1) && roundNearestEven) {
+ absZ0 &= ~1;
+ }
}
if (zSign && absZ0) {
@@ -3603,7 +3609,9 @@ static float32 roundAndPackFloat32(bool zSign, int zExp, uint32_t zSig,
status->float_exception_flags |= float_flag_inexact;
}
zSig = ( zSig + roundIncrement )>>7;
- zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
+ if (!(roundBits ^ 0x40) && roundNearestEven) {
+ zSig &= ~1;
+ }
if ( zSig == 0 ) zExp = 0;
return packFloat32( zSign, zExp, zSig );
@@ -3757,7 +3765,9 @@ static float64 roundAndPackFloat64(bool zSign, int zExp, uint64_t zSig,
status->float_exception_flags |= float_flag_inexact;
}
zSig = ( zSig + roundIncrement )>>10;
- zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
+ if (!(roundBits ^ 0x200) && roundNearestEven) {
+ zSig &= ~1;
+ }
if ( zSig == 0 ) zExp = 0;
return packFloat64( zSign, zExp, zSig );
@@ -3983,8 +3993,9 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecision, bool zSign,
}
if ( increment ) {
++zSig0;
- zSig0 &=
- ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
+ if (!(zSig1 << 1) && roundNearestEven) {
+ zSig0 &= ~1;
+ }
if ( (int64_t) zSig0 < 0 ) zExp = 1;
}
return packFloatx80( zSign, zExp, zSig0 );
@@ -4000,7 +4011,9 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecision, bool zSign,
zSig0 = UINT64_C(0x8000000000000000);
}
else {
- zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
+ if (!(zSig1 << 1) && roundNearestEven) {
+ zSig0 &= ~1;
+ }
}
}
else {
@@ -4270,7 +4283,9 @@ static float128 roundAndPackFloat128(bool zSign, int32_t zExp,
}
if ( increment ) {
add128( zSig0, zSig1, 0, 1, &zSig0, &zSig1 );
- zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
+ if ((zSig2 + zSig2 == 0) && roundNearestEven) {
+ zSig1 &= ~1;
+ }
}
else {
if ( ( zSig0 | zSig1 ) == 0 ) zExp = 0;
--
2.25.1
next prev parent reply other threads:[~2020-06-17 20:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 20:13 [PATCH v4 0/6] Vs clang-10 and gcc-9 warnings Richard Henderson
2020-06-17 20:13 ` Richard Henderson [this message]
2020-06-17 20:13 ` [PATCH v4 2/6] migration: fix xbzrle encoding rate calculation Richard Henderson
2020-06-17 20:13 ` [PATCH v4 3/6] configure: Clean up warning flag lists Richard Henderson
2020-06-17 20:13 ` [PATCH v4 4/6] configure: Disable -Wtautological-type-limit-compare Richard Henderson
2020-06-17 20:13 ` [PATCH v4 5/6] configure: Add -Wno-psabi Richard Henderson
2020-06-17 20:13 ` [PATCH v4 6/6] qht: Fix threshold rate calculation Richard Henderson
2020-06-17 20:58 ` Richard Henderson
2020-06-19 17:31 ` Peter Maydell
2020-06-18 10:22 ` [PATCH v4 0/6] Vs clang-10 and gcc-9 warnings Peter Maydell
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=20200617201309.1640952-2-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.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).