From patchwork Tue Aug 13 12:49:36 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: 171185 Delivered-To: patch@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp857988ocp; Tue, 13 Aug 2019 05:50:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxhpwfY08YYRyK6GOdc/BojO9LS/MBKFgha7c1DGyo2IOtCCzP7oRz2GrpVk4cqXCaa9RC X-Received: by 2002:a17:906:ccc3:: with SMTP id ot3mr36054486ejb.113.1565700645451; Tue, 13 Aug 2019 05:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565700645; cv=none; d=google.com; s=arc-20160816; b=kGxRubmgJxpUJY52oEIsioQyKbar9854xSYlo1KH4I0tlEVzfYcTC7w2xzIY2KhPi8 T8KNrEJ/DcXko/hweiwIY1ef1FOP0jkPRIyaemQG5r4uMpw2FnVo1ODwo3jVS+INuKb7 yc/7wnvwNaY8KdAvbptYH/I5PuVl6vZLHJInpkiL/WgDbGNKpKZ4j3slpkbu/QEbAgch VXcPMQ1ji2ZTKp3leKGQTWfq0VDIj8fzUlVGL0yr++dreDsSDMmblJfOjFRahMHKavk+ VheajzjLu7Emv5MoKgZAfMxiYEJTgpN7Bjh/HP71OtlAlS/Q9rEs5BjaHEbGYrn2PXRV CtoA== 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=bzhZ2dvCDc+pUSd5l57iGhNYKTcXOEr6qbHitn8Zc+c=; b=whgVjr5T5QpI3l95zjz/j7bGxIPwmpFxCRUG7JMa1fW5b38Bi9LyfW53kQ3dJLOT1l A4aiMUBHXjjjs6/nYQUqp6s96porh+KFSuU42a+5GNun+MuN5oyzmQzPHaI0Imm4L95z YvhhmcEEgtGiQeVSHEkgXnLmHK/auLK3UzUexETZt3Ja0jX7KXW2HzScIMIqlbjmaq6L ev0x2k2DEKA+pjS5icoxsZG6j+9H7L/JEXjRQHkZxGTTHysjEZJaaAKzfMhEgmvr8rQ8 liabQ+LnhYgJgEcufyHwnOVlGghet92JZZraUEvytJUDiOY675YmObkbLq6KuT5DaPDA eUZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=h982IvVq; 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 f27si10032873eda.267.2019.08.13.05.50.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 05:50:45 -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=h982IvVq; 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]:51984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWGC-0002NP-6Y for patch@linaro.org; Tue, 13 Aug 2019 08:50:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53558) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWFM-0002Gq-Bb for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxWFL-0000eZ-1I for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:52 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:54932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxWFK-0000dI-RM for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:50 -0400 Received: by mail-wm1-x341.google.com with SMTP id p74so1391013wme.4 for ; Tue, 13 Aug 2019 05:49:50 -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=bzhZ2dvCDc+pUSd5l57iGhNYKTcXOEr6qbHitn8Zc+c=; b=h982IvVqIYV+ZjyA983mzieTIw4nGQdNXcRCXtWG4Xn6pyY7A8JKwtV/weaGCOla/+ 3pIJJdyOTmEAGTnGpldt+tKp1rk5014Qfmo4TEfJuDYd4TkBsvFbn99P4cPjDV+Y3RPF rXHrds7mqRzSUST2EFnNoGEnNshWY9tXMhw7s4D1HhlNpwGs9EKvMTV91HtKWSRJnzL8 sF5vHcU5v6Rmjra/Qq1ffFinp1K3cLSgMHmbd1Cz03Cie/Ja0xFJ+Sza2tnTEQ6YpT+m eK4ax7sDZgVBdQqyPraxdecytXymdttXBQAfX1bvO3/Lqz9VYD0ovdZOIBRL9qqSYs+U a+WA== 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=bzhZ2dvCDc+pUSd5l57iGhNYKTcXOEr6qbHitn8Zc+c=; b=M00A1trmKLwQzbMv/K+x7rATjxuoVL853XDrBmKLeKXQ5LaGmmHDeN3uD9ZrUK3Joi AD2HCN/WcEjsp0FylBl3Oz8JE2eFtY4+6CnenqV3gfH7qUZoM1+V40k55JF0Z9jQCld4 Ih/6Pun/QAqcm/CQiGL63QRtsVlH0D8lU3fOsBZMDRX1NKiZTZcwEC7zwh5mqpISUz3G JgroHHW3W/yW1SMByFVmXIfAKDNpRX+T/TkKzU0/oMhRQdZ0l/tCCrulEzFKfk31mqWw vqV7RAVtSCsNVaXJ9iXb96khY8+QPRW21wbMB0U/XS5gkd9tnkXO2axPRGyjAyoEzRbG bCgA== X-Gm-Message-State: APjAAAUvxcu7bDGBGE5b2tj+uoAfMR0dpjkTKSjp1z17i5Q6+vyb5zZs +5kSLhYIEjUxNKWWzkKKZfDSxQ== X-Received: by 2002:a7b:ca54:: with SMTP id m20mr3060824wml.102.1565700589733; Tue, 13 Aug 2019 05:49:49 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z18sm954417wml.10.2019.08.13.05.49.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 05:49:48 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2DE231FF90; Tue, 13 Aug 2019 13:49:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 13 Aug 2019 13:49:36 +0100 Message-Id: <20190813124946.25322-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813124946.25322-1-alex.bennee@linaro.org> References: <20190813124946.25322-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::341 Subject: [Qemu-devel] [PATCH v3 03/13] fpu: optimise float[16/32/64]_squash_denormal (HACK?) 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: Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , armbru@redhat.com, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Using the floatXX_pack_raw functions is slight overkill for basically just masking out all but the top bit of the number. This makes the final code exactly the same as pre-conversion. TODO: is this worth it, can the compiler do better with make_float? Signed-off-by: Alex Bennée --- fpu/softfloat.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 0a434555cd8..9e57b7b5933 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3294,23 +3294,23 @@ float64 float64_silence_nan(float64 a, float_status *status) | input-denormal exception and return zero. Otherwise just return the value. *----------------------------------------------------------------------------*/ -static FloatParts parts_squash_denormal(FloatParts p, float_status *status) +static bool parts_squash_denormal(FloatParts p, float_status *status) { if (p.exp == 0 && p.frac != 0) { float_raise(float_flag_input_denormal, status); - p.frac = 0; - p.cls = float_class_zero; + return true; } - return p; + return false; } float16 float16_squash_input_denormal(float16 a, float_status *status) { if (status->flush_inputs_to_zero) { FloatParts p = float16_unpack_raw(a); - p = parts_squash_denormal(p, status); - return float16_pack_raw(p); + if (parts_squash_denormal(p, status)) { + a = make_float16(float16_val(a) & 0x8000); + } } return a; } @@ -3319,8 +3319,9 @@ float32 float32_squash_input_denormal(float32 a, float_status *status) { if (status->flush_inputs_to_zero) { FloatParts p = float32_unpack_raw(a); - p = parts_squash_denormal(p, status); - return float32_pack_raw(p); + if (parts_squash_denormal(p, status)) { + a = make_float32(float32_val(a) & 0x80000000); + } } return a; } @@ -3329,8 +3330,9 @@ float64 float64_squash_input_denormal(float64 a, float_status *status) { if (status->flush_inputs_to_zero) { FloatParts p = float64_unpack_raw(a); - p = parts_squash_denormal(p, status); - return float64_pack_raw(p); + if (parts_squash_denormal(p, status)) { + a = make_float64(float64_val(a) & (1ULL << 63)); + } } return a; }