From patchwork Mon Mar 25 13:20:06 2019 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: 161103 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3969419jan; Mon, 25 Mar 2019 06:26:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfpeA0sBENH4UZ67arFF82msZ9/Prycin/iaiZsKnE0DXpNm1xh5+A395Dy+Aga+AI3pwS X-Received: by 2002:a25:65d4:: with SMTP id z203mr20223692ybb.370.1553520360087; Mon, 25 Mar 2019 06:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553520360; cv=none; d=google.com; s=arc-20160816; b=a4gd7xmSuam4Lqj8axbrZicSboTfD27r8joxXcAH56/S2O9dcgQstQbaD/QFs49tuR vUZGWAfcq2CrmCuu86kWlPnc3UETTKB0FBwYC77YIiP+lEF1unNYJ6rLxibG2yiW62Xh UltEiAQE1Qt0VvSNNgMWkDOsAP92j/ewW6lJDnRxOKG6DCDnpYJZ/Vq+T2GOzWrC0kV3 457j0GBWGXToUx7JshqOANrlj8xGYlbNx9MfYmOjKXilJFSfvo0Nb8zZMOb7I8Dt/yYJ 7nUNec8Umy0nXzhGrY4sOE9ix4Vif6fnMop9Adfuoxgi9mkTxAMGJdnsoS4qFjijjmDY gArQ== 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; bh=c1aVuJd8adxgw3j3f84WFBDQvPzcBUzxKhHsQiyR778=; b=cqL3xsHELtxle4OX9OVEiAuPDF6BHPILl1BRpX8ATLt+fUMCKhELmOs5Zhy9kp2g1N Jw746XakKGYPKDYJyMRMB+gk1rFb9S3nFuojfX3cvxD9AhPlGFkn0sAA56fdHiPKYT3e FsVcXgGDxxpkb+dptuoclTAdYvdGaitvf4PPjEfE4qkCfw1QXZrkfKdON6iaf6L0t6Fm gTfVt9aC3HcxiiFZD0CAjFiQjxXLkx4oomCrtk1NQPMRAOQ0yxQ39gxW1H0RIH6qfnEx xPPFnmWc2NQHJik80ObMRmGlli4xaVr8ZZKI6+U5pluRrYTGfh63clf6zrrIUQlcOQue zKEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cvLo4M5h; 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 145si4627149ywe.301.2019.03.25.06.25.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Mar 2019 06:26:00 -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=cvLo4M5h; 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 ([127.0.0.1]:42563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Pbz-0000BY-Jl for patch@linaro.org; Mon, 25 Mar 2019 09:25:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8PWd-0004GT-F8 for qemu-devel@nongnu.org; Mon, 25 Mar 2019 09:20:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8PWV-00056i-UL for qemu-devel@nongnu.org; Mon, 25 Mar 2019 09:20:25 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h8PWT-00052l-VL for qemu-devel@nongnu.org; Mon, 25 Mar 2019 09:20:18 -0400 Received: by mail-wm1-x343.google.com with SMTP id f3so8922408wmj.4 for ; Mon, 25 Mar 2019 06:20: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=c1aVuJd8adxgw3j3f84WFBDQvPzcBUzxKhHsQiyR778=; b=cvLo4M5h4HIk0LFJwT9Muq2JFOwoDSgzJt9ijXnzdStLiBe8jX8Pv0IbpWE79IS1L6 xLCdsFEAJz58VJOdceP5RzQxrQs7VtfhTXaqJNlCfF/U0DuDLvwF+GYqu/HAM4UjRICm pmhnzYwZZ05l+AFdSRBTo49A0xoFDDO9hRT8uRDdGqwR8fTqatoXy09BFFukHEAx6KGW 5aNycoGBj8YdzsccaGkFD99M1db2v33UGiMNQxbpz9sQ8Vz+21j8r86id3YM0o2GC60N LZFv4E2/J5F1ns71aQD5nj2TMMD7IacE908GMYbusxwtGK5FcateEPvT+1qX2i6Z+V/9 3O0Q== 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=c1aVuJd8adxgw3j3f84WFBDQvPzcBUzxKhHsQiyR778=; b=tmc8lDrfL4wRQfUr0F99Aw4GJD9t5FVsJjoHN6P1YxtnIBmqwVCgFtLDZ7n0BG3Btn tlYLA4tcNgX2N+9omHTNZnXRCpCETw/tUkMbUbNJjiCV+h0l4si2SAvMzgD9efjugrE9 eNA7K9Rl4tHClie2cVVI6IvtM4VH0GGg5qFK1sCH8tvVpn4l2CtTRz2t7HjDLY9EyZqR h0hYnAsN/ahRjqRyT/Chx4gXgaRRlRSs8u7SH3Kz1QOQxmb7boLH1jQKz0sgfwM49zyo hvTy6D14t37Y5VBIBK1ivzduvxt9oNNnD1vHIoD12xuzrqyURPJJIr5iMKCtnbZFRJjI ykSw== X-Gm-Message-State: APjAAAV2RHviAXbuRUYgy2ecm374vXs4k6UH7awlQ3U/GmH9s69TY9tV U6zVvyXN4s8nZbOdD4ZMQyJcWg== X-Received: by 2002:a05:600c:2210:: with SMTP id z16mr11245411wml.57.1553520014631; Mon, 25 Mar 2019 06:20:14 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j1sm18628114wme.4.2019.03.25.06.20.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 06:20:11 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E26A51FF93; Mon, 25 Mar 2019 13:20:09 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 25 Mar 2019 13:20:06 +0000 Message-Id: <20190325132009.14987-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190325132009.14987-1-alex.bennee@linaro.org> References: <20190325132009.14987-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PULL 6/9] hardfloat: fix float32/64 fused multiply-add 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: =?utf-8?q?Alex_Benn=C3=A9e?= , "Emilio G . Cota" , Richard Henderson , qemu-devel@nongnu.org, Kito Cheng Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Kito Cheng Before falling back to softfloat FMA, we do not restore the original values of inputs A and C. Fix it. This bug was caught by running gcc's testsuite on RISC-V qemu. Note that this change gives a small perf increase for fp-bench: Host: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz Command: perf stat -r 3 taskset -c 0 ./fp-bench -o mulAdd -p $prec - $prec = single: - before: 101.71 MFlops 102.18 MFlops 100.96 MFlops - after: 103.63 MFlops 103.05 MFlops 102.96 MFlops - $prec = double: - before: 173.10 MFlops 173.93 MFlops 172.11 MFlops - after: 178.49 MFlops 178.88 MFlops 178.66 MFlops Signed-off-by: Kito Cheng Signed-off-by: Emilio G. Cota Message-Id: <20190322204320.17777-1-cota@braap.org> Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 4610738ab1..2ba36ec370 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1596,6 +1596,9 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s) } ur.h = up.h + uc.h; } else { + union_float32 ua_orig = ua; + union_float32 uc_orig = uc; + if (flags & float_muladd_negate_product) { ua.h = -ua.h; } @@ -1608,6 +1611,8 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s) if (unlikely(f32_is_inf(ur))) { s->float_exception_flags |= float_flag_overflow; } else if (unlikely(fabsf(ur.h) <= FLT_MIN)) { + ua = ua_orig; + uc = uc_orig; goto soft; } } @@ -1662,6 +1667,9 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s) } ur.h = up.h + uc.h; } else { + union_float64 ua_orig = ua; + union_float64 uc_orig = uc; + if (flags & float_muladd_negate_product) { ua.h = -ua.h; } @@ -1674,6 +1682,8 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s) if (unlikely(f64_is_inf(ur))) { s->float_exception_flags |= float_flag_overflow; } else if (unlikely(fabs(ur.h) <= FLT_MIN)) { + ua = ua_orig; + uc = uc_orig; goto soft; } }