From patchwork Tue Apr 17 02:53:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 133501 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp4234505ljb; Mon, 16 Apr 2018 19:54:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48P/aGbxrwaw9eGtpItj3wCSyaovn7bMH0OVg9VtZMrARG4Udo0M7t7O2pZyyQ1wlfmzwPF X-Received: by 10.55.164.136 with SMTP id n130mr382237qke.13.1523933642501; Mon, 16 Apr 2018 19:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523933642; cv=none; d=google.com; s=arc-20160816; b=BQeooNCzofgojyH0I9AXJi4kevF4T5gazIgnBIWmtqyWEllZM62li6Nac84GnSKcgd YmlIkzP5CjrviBXB/+f3+QxQ95bf8o6lvmbPVjFdmTMjmYBFFpXRc8E8RQU3654RU4t+ JWdWVnwoRXXd5xuW+n8BaFYDglH1p3PxkhJL9VMRByVcXIe7ifLyrbv864nw7nXzIM/o XzFcH/4Xf1Zmvkxl+s02zBVHj6EEsS29D0y5DHYA1f5wKcUfJ+OY/NNLuFWOfJZL0T0L xAkKOihBekXVAcza4WYxhR2O0+IXAr8gSP4aTsVtux0lXdasf1TeX+sUiPbvSsF0V1uq uxVg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=aIrJdcd3Rlf4G6pjMgn7JXWzwVirCr0wwO7ntLRq2WM=; b=YFN1t2vSF/XZmIS6RDCGy2xBABcSGN6Fnk3j/u01BKm72+mMChJcv16eGsJlVFSBZW mouvnnbd7A9HKRgVkMQoi8XgYyvFHvwhgd2FTBCh2jgSd43FOqnlqcfXGqvTtepQG7fB cQUeoi6DK32Zmj26M6IfXG4e9NSpMU6KkTo8J1I9ghbNglwOkyLouDmOa99iDwOJG/mU iDxac2WkjmH0faFzVxYM3I8GqIamz8/scgEWj/Od8GO2no4B/AQQDtyDdekQZe4rfMK5 LGwNCgJtbbfIlIaiSzaSaLFMdQxxbMNQmR0OdAfqWwPdtLNOQ3ztk68S2ymJ2ojQlWYN zKZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dgHUzS5G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e68si1719010qtb.72.2018.04.16.19.54.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Apr 2018 19:54:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dgHUzS5G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:34574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8Gkr-0004SO-VF for patch@linaro.org; Mon, 16 Apr 2018 22:54:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8GkT-0004RH-UP for qemu-devel@nongnu.org; Mon, 16 Apr 2018 22:53:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8GkS-0007ab-CT for qemu-devel@nongnu.org; Mon, 16 Apr 2018 22:53:38 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:42579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8GkS-0007Z8-6p for qemu-devel@nongnu.org; Mon, 16 Apr 2018 22:53:36 -0400 Received: by mail-pf0-x241.google.com with SMTP id o16so11458307pfk.9 for ; Mon, 16 Apr 2018 19:53:36 -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=aIrJdcd3Rlf4G6pjMgn7JXWzwVirCr0wwO7ntLRq2WM=; b=dgHUzS5GGx0qQUhjEXa8DHbd6K/HAftMqAVFeGuqMEEllJHHvECngeFEI2+eA65Ezo zCs0gWmuP9quULFJV0k/NXE/uqpZdBS21VA7izKrXjzrFJqvxOg/pYJ8inFpB9TnDm2s 6wziB2HRtpqP/9EzMvQVRFQl3S7kAjHyqtUYY= 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=aIrJdcd3Rlf4G6pjMgn7JXWzwVirCr0wwO7ntLRq2WM=; b=YtHEFy2rTCB99R732kZasAWQLfJky3kUh7c47/3AXdlCVi3ybDP5qG90vrjksrVGuW 0VbqzP4CTI2lvWS7HC+BnpCBTWYDLGSQIS7ZvCc0FxXIVDcJ/00gdPniok47jRAr1gQP Xu2DFnYOtFwx/hiCHjwZ5P88d5is3z85qgt7RzguBpQTPXx/4IcY8uQIpXZZuMeONppA HeGXZYYrJct7oLzl4Bz9CQIBakAj35QZeAt3OKn0JSjrA45xEH8Gyj9p5ykDtBD49eYi mMp593jODfXMf3ybSqzH/nPn4gjht+kCuJD7mxuoIUL7+Quclaj/UD3M1JX+/E190OAF 3epw== X-Gm-Message-State: ALQs6tAZrKjgPpQau0YFBbUWEZAy1Gwjsk789zUx0pPXJWT7t9tDlG0V lAge8JB2VbmnPg6U+B6wmL0sQQ5bXoY= X-Received: by 10.99.147.20 with SMTP id b20mr272635pge.309.1523933614832; Mon, 16 Apr 2018 19:53:34 -0700 (PDT) Received: from cloudburst.ASUS (cpe-66-75-76-48.hawaii.res.rr.com. [66.75.76.48]) by smtp.gmail.com with ESMTPSA id v63sm31759876pfk.8.2018.04.16.19.53.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Apr 2018 19:53:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Apr 2018 16:53:27 -1000 Message-Id: <20180417025328.25431-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180417025328.25431-1-richard.henderson@linaro.org> References: <20180417025328.25431-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH 1/2] fpu: Check for inf/x before x/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, alex.bennee@linaro.org, Bastian Koppelmann Errors-To: qemu-devel-bounces+patch=linaro.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. Cc: Bastian Koppelmann Cc: Alex Bennée Cc: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.14.3 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index fb8663f59e..ba6e654050 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1146,15 +1146,20 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s) a.cls = float_class_dnan; return a; } - /* Div 0 => Inf */ + /* Inf / x */ + if (a.cls == float_class_inf) { + a.sign = sign; + return a; + } + /* x / 0 => Inf */ if (b.cls == float_class_zero) { s->float_exception_flags |= float_flag_divbyzero; a.cls = float_class_inf; a.sign = sign; return a; } - /* Inf / x or 0 / x */ - if (a.cls == float_class_inf || a.cls == float_class_zero) { + /* 0 / x */ + if (a.cls == float_class_zero) { a.sign = sign; return a; }