From patchwork Mon Apr 16 13:54:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 898632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aBvy4Gg1"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Pqdm58b0z9s25 for ; Mon, 16 Apr 2018 23:55:23 +1000 (AEST) Received: from localhost ([::1]:47849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f84bH-0005FU-WD for incoming@patchwork.ozlabs.org; Mon, 16 Apr 2018 09:55:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f84at-0005Ez-0Q for qemu-devel@nongnu.org; Mon, 16 Apr 2018 09:54:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f84ao-0006sj-Ha for qemu-devel@nongnu.org; Mon, 16 Apr 2018 09:54:55 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:35030) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f84ao-0006s3-AW for qemu-devel@nongnu.org; Mon, 16 Apr 2018 09:54:50 -0400 Received: by mail-wr0-x243.google.com with SMTP id w3so9666585wrg.2 for ; Mon, 16 Apr 2018 06:54:49 -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:mime-version :content-transfer-encoding; bh=pLOVXbeK9evdtcgh80za8oGiMzAxoj5RD8AFaTXhP7E=; b=aBvy4Gg1xSEA8W4w9yfCAwIe5W2127ASxA+HF+HFLamVk8CsYIVkAjgDahONCaTKS2 z11LviiqhDAUNfj35Ok7/4U4pRltiZr+6JtcuEyTjp8cMt0WKmrXUJiFcfNUjXqKX8+/ kkm/5EQGG7qhx40CdJYozhvnwFxSITIeKwBXM= 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:mime-version :content-transfer-encoding; bh=pLOVXbeK9evdtcgh80za8oGiMzAxoj5RD8AFaTXhP7E=; b=gst4zZseVcOcUVQz2NAzR8OF7Vpdeifj5mIw+EG+A01EP9ORzONF+1fsCRozorPwA6 8p2nNLay0795baS6C1DNXU+hN5zBFA3tYXMHMmrXjJY2qxp6TM4FwCpUsKfmEC8NTwOu V3iuGrkrDXdyWLDiwq0B8Cw+WlDbbSoIjqNWxFWnT5YTp0IptZuq45cJPtj4w6dQmXqN 3B6uXVzKww5mBfjNAlm1GcnGYr6AuBN5uRbNTsdjcl+TuRyuRbDBNR+0xzWpZ1Z3jVxd dFSowSjVknG/DNkouV5LGLeCVHjjKSKPxMsBE40IXRAjbYha5v33xaLAcx1ALmgMmHfU Q8oQ== X-Gm-Message-State: ALQs6tConKQ+DO8hVWVOxuz/WEJHLHZEA1xZ9vpcsnlD9GXTsP3QffFy FMRAmkUHS7Kx2kDAcWoC5IehCw== X-Google-Smtp-Source: AIpwx483f5vigDD90zDLJtF9NM7XngGDhrT5qsegPg9kuDenbISJlPDw/yGBSpq8om6Uj1lHB1koPQ== X-Received: by 10.28.122.15 with SMTP id v15mr9892994wmc.91.1523886888807; Mon, 16 Apr 2018 06:54:48 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t8sm8764974wmc.20.2018.04.16.06.54.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 06:54:48 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A5A2F3E01CA; Mon, 16 Apr 2018 14:54:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 16 Apr 2018 14:54:42 +0100 Message-Id: <20180416135442.30606-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH] fpu/softfloat: check for Inf / x or 0 / x before /0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Bastian Koppelmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The re-factoring of div_floats changed the order of checking meaning an operation like -inf/0 erroneously raises the divbyzero flag. IEEE-754 (2008) specifies this should only occur for operations on finite operands. We fix this by moving the check on the dividend being Inf/0 to before the divisor is zero check. Signed-off-by: Alex Bennée Cc: Bastian Koppelmann Reviewed-by: Bastian Koppelmann Tested-by: Bastian Koppelmann --- fpu/softfloat.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index b46dccc63e..a7d0f3ff56 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1146,6 +1146,11 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s) a.cls = float_class_dnan; return a; } + /* Inf / x or 0 / x */ + if (a.cls == float_class_inf || a.cls == float_class_zero) { + a.sign = sign; + return a; + } /* Div 0 => Inf */ if (b.cls == float_class_zero) { s->float_exception_flags |= float_flag_divbyzero; @@ -1153,11 +1158,6 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s) a.sign = sign; return a; } - /* Inf / x or 0 / x */ - if (a.cls == float_class_inf || a.cls == float_class_zero) { - a.sign = sign; - return a; - } /* Div by Inf */ if (b.cls == float_class_inf) { a.cls = float_class_zero;