From patchwork Wed Jun 17 20:13:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 190892 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp766462ilo; Wed, 17 Jun 2020 13:13:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKiHDOO6ugSpDbDb8M7hlFjj7JT/DctObIc6bErEziOnNFhLYwgTjSOh0C2ENks1q9yQtA X-Received: by 2002:a37:48cc:: with SMTP id v195mr417410qka.232.1592424809509; Wed, 17 Jun 2020 13:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592424809; cv=none; d=google.com; s=arc-20160816; b=W+lSVbXiA1iO7ozJc5y2mb0RyN7UgZ3HEgvBPVQjm6i42L31wxJn/LlVFI6Zq3JBq7 XYq3R2D/X5MOpHU3u+Xd+jN4Z0Wnk3ip1ObT28U1/QAqRfYRe7tL0JU9IiC4/TZs67vU bVqXKqF7o0eMTheXtQl9iiyGBBGYPaQq/X60rEZLktNOMQOnp1nkbRn8gVU8kAdqNvxy 2zIFvAXij3j+4E3H7kwbzPWBG6pDPcQ6xSFWMFXcCJ5BZVimGAzoHyzBbM2xyaUzClFR 06X03Bm9U1grsUS8AhjKh5ujIE7LfU6gfnTcmJjf0w/4/39Myid6KW120ZR+WPjgBXpq TQfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=p5hi1MkuSub3noZRf3bAcEWN2K9bQNMhFTxTeY7Mp2k=; b=ARyE3f41mm9+cCSY8PA3xHWRi7h6XRk2+vatrwRHagdoo1ebk2gCN+lwWHoFXxygBC ivwlPwemzfjir4uyDX0Imsv/RooV8asIt3+9hyL6qunt/YT2WdTn7ZdnwnlQQfSiVBKm IC0k1F+1rskmfN/f53rCsMY7DVxALsW7wzJ3OsZ4erG3vR3b5cxkW+OUT4M+NnnJkxje Ba7fyeg9vHsUtKiig7jpZhz4ccl9KLpTWOx7Hs3kVhtife4Kx/rsObZkFFPjUyN7hjEh kwmjInkBAtQcrNKnmlG2EbDdph+6iaHckC7HLGoW1m8tpeiVjZDfFcrzMhmwV+OXG8EZ 1PLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nh3qFhU1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x13si364756qvu.152.2020.06.17.13.13.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Jun 2020 13:13:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nh3qFhU1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jleR6-0005ic-U8 for patch@linaro.org; Wed, 17 Jun 2020 16:13:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jleQv-0005gN-Sw for qemu-devel@nongnu.org; Wed, 17 Jun 2020 16:13:17 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:38726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jleQt-0000Gh-RM for qemu-devel@nongnu.org; Wed, 17 Jun 2020 16:13:17 -0400 Received: by mail-pj1-x1044.google.com with SMTP id d6so1595865pjs.3 for ; Wed, 17 Jun 2020 13:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p5hi1MkuSub3noZRf3bAcEWN2K9bQNMhFTxTeY7Mp2k=; b=nh3qFhU1W5Z+ANI6yzZJ515l6lYebwVwSPg5s+sGIsejz37TYYpnpVLKZytYhNVaFd HUR95MrdBBqrXH5GkONqS4xIiLGQ/2/1+RkCGWvuWPWBZ5DCfvN7QnYQ97rUaxIS+XNd yxPQRqk7PrFfTkXegQyBfRl76w1kM2vnDIOs16UPvOPGXOiXQU2YG9McfjZZMKumvsnJ UuiseNt0NaqM/antrFOTIaJa8Z4bxpXXiLv4eCzv7TzPUg+Pn1t/62iWPyUixZszl/XC 59jggqzK6CWzU/LYiPkHciPJGLVsgHGG0H4/YWRGNAj/LMgGmrm+wY3CnlOon4hb9nPy v/pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p5hi1MkuSub3noZRf3bAcEWN2K9bQNMhFTxTeY7Mp2k=; b=WJqxuaKurIo5XYSl2+rNK8ku0L3ojEDFDBvP+ednOO/m9vzCMPV1aMtCvZIdG33xOx Wbm75U4IbIrDgKWHGUpya2NUIrLKYW/PKA3BEoZnFqqDsLl871okfmHpg37psMYv10bE vjyU5UM9lVXkBFVbJ0lSMaokRQ1yzJngWDpJtEUh9ZDRjbMwwHL5oyxpl3/THlmKJPxp 0IFzORkM+WKW9xjIi005MH7E1QJXlyVQZX5RxtB7Xj2EpSoLMitBtWaBrTNDKQMql5vy jW2Lk+Nad6gZ3N/eDxlVOAI215OP325e596M1k2EBqG/kNx4LgS41BlgP6WKSDlpaSqM v52A== X-Gm-Message-State: AOAM532MXT00bnCeGhFbbB6oc9e5oqwQmyuyxjAT7Ec6B2eZReGJ9yXK eHewKCJAxKO/gLx42/4Xl3KisJwOp4w= X-Received: by 2002:a17:902:eb14:: with SMTP id l20mr708188plb.189.1592424793873; Wed, 17 Jun 2020 13:13:13 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id h9sm659259pfe.32.2020.06.17.13.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 13:13:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 1/6] fpu/softfloat: Silence 'bitwise negation of boolean expression' warning Date: Wed, 17 Jun 2020 13:13:04 -0700 Message-Id: <20200617201309.1640952-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200617201309.1640952-1-richard.henderson@linaro.org> References: <20200617201309.1640952-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1044.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philmd@redhat.com, Thomas Huth , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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 Buglink: https://bugs.launchpad.net/bugs/1881004 Reviewed-by: Alex Bennée Reviewed-by: Thomas Huth Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200528155420.9802-1-philmd@redhat.com> Signed-off-by: Richard Henderson --- fpu/softfloat.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) -- 2.25.1 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;