From patchwork Thu Jun 3 21:41:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 453316 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp628300jao; Thu, 3 Jun 2021 14:46:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlj0IMAkBF6J7HnQDbgezyz2hnNPyB3vGE+J9buTQ7SR/8uk3o8yZJ+b+84krf4w96GDzO X-Received: by 2002:a1f:6dc6:: with SMTP id i189mr506837vkc.19.1622756766623; Thu, 03 Jun 2021 14:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622756766; cv=none; d=google.com; s=arc-20160816; b=CZS9z5SPdfAcTBqAuQ7baDxACqGGdcsGKN33z5WM46avawAt/GC15UsdUN/qhYrMd7 of8KSFGAVF/kBBQgqDuANjIuvDbhcQhBdltc1yHHm+pan7YXoLBbjBGZT2odQpv0PjgZ VFm4aVZcYbuozuQdvTqw8y2ycRj8bwEsfOzY3fhN4iW3xTHIdceENK8kG5CpXFhZI/6L AzZ7E/QXZMwi5q4Wv2V7aBn0TRlDrKcY6ot0QQ2qrQBU6vnP7bWuRMrVHyosuK4Su3Gp Xn5wQn4YIjTWIdl1SrttUaVyN0h1BJCYDDm0FyGcEgHoO/u+Lq3vNTPednj8HePqwiYq OQqw== 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=ppZ1jH79N3swPQMu5gvh4yX8BmZmZOhaiSlhleLfgRI=; b=G91PlmohxYsqcMyd8qUoxFaWTnbofdLeD6gz/boBRogJtolqoRFY8ds0Bh14b+427K RjVw1Ej8ZlM6tU+YMBxkLBcScHm0KlHIbaRrwV64rPuin0Qkcmwl0iNoTQlwyWuSQxdq +sZt6w18xSwZFCWQM2rMRL0fOJNKjK5fW5YPQlJLbWyxbrjy3hDqUvbPmL5pNotpMLIw 4O/F+W/oxYCRFwG4mB/BcszXOMH84sPTvYaUXn3SDZKchm1rLsO0ezrRE60lrNq03ELu NDurVsmjtRkci8yExSG52WeKJdrbdcAsgW3E/9Qm1SDnzwmWMunJOybcWQySObqNsj20 568w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WhqXS0Sn; 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=pass (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 l8si1370730vsq.378.2021.06.03.14.46.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Jun 2021 14:46:06 -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=pass header.i=@linaro.org header.s=google header.b=WhqXS0Sn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lovAD-000596-Ui for patch@linaro.org; Thu, 03 Jun 2021 17:46:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lov5z-0002Ex-Gq for qemu-devel@nongnu.org; Thu, 03 Jun 2021 17:41:43 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:44020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lov5w-00014r-Km for qemu-devel@nongnu.org; Thu, 03 Jun 2021 17:41:43 -0400 Received: by mail-pl1-x630.google.com with SMTP id v12so3580090plo.10 for ; Thu, 03 Jun 2021 14:41:40 -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=ppZ1jH79N3swPQMu5gvh4yX8BmZmZOhaiSlhleLfgRI=; b=WhqXS0Sn8Talgk2LHvsCcZ0eoJvIQSuH9KMIaqVPwzFt/CXUvmIBjNySjuzYC6Bogq mzuoosyX6GhaZa/e45hUP6GhjRRLYjmcE8kbu2kAtCeXxGasnunE/TZ8Gp6Nt5+x4nC6 /l3hecSz/CUQD8uMg+fkWJLW4xmSS8zd+MsMHlwoirJrpwMv0aslwqRChbgxPYznGaB1 8ZamjSTbe9x70w7cfCFtd4Pcu/DQDxbAiSEHLj1CS+9IVEsZLsRVL+Vy6CzdSomTAanR kQ6c40+jpsSRNhk9nqy4vbKOEqCZNqvNMe5n3pGq9t6fw7zocJ04O/1Uhmfn5Zq3Q7U7 d+bw== 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=ppZ1jH79N3swPQMu5gvh4yX8BmZmZOhaiSlhleLfgRI=; b=nizagitmPVRCXExu8KaGeqKtRZ8/9n0dG3GEaEZYWBNlKOSP2atWM8SONpzxr2lCM0 YuSEszSgsDJGw/ZnVKNI7iOSBc2EGeIPjV8Rf2YZSD54/wAz8Ahk+Cv89TzcbYjLWMnm H1SnBRGpKyuK9CHhbgO5BhzfYoMxIuoJtzR7K10GUAqzEtvk9PRr835kcAXJ/vwvzCD/ NxznkEBzxX8TvkxAJEjh2i6cIzaa4Bjz6q4xN8EReBiO1B7dEv8kFGCTlT7oVvVpX39+ Fot+OPdM6k9Npadlon8hKgDZHp5zPSJZtnbSwahw2+jzv5wkZBcz2y4yAsfekFG89b5L yl/w== X-Gm-Message-State: AOAM530cBmigjxrTy0eoPpST40iLSmmrzlioUJU+C2PBnQUOWXLniEzB +K8JB6V9BRGCDT5tGH3g1cakRWgvshyj2g== X-Received: by 2002:a17:902:cec3:b029:10d:22fa:183c with SMTP id d3-20020a170902cec3b029010d22fa183cmr1189303plg.53.1622756499291; Thu, 03 Jun 2021 14:41:39 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id p65sm40115pfb.62.2021.06.03.14.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 14:41:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/29] softfloat: Reduce FloatFmt Date: Thu, 3 Jun 2021 14:41:12 -0700 Message-Id: <20210603214131.629841-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210603214131.629841-1-richard.henderson@linaro.org> References: <20210603214131.629841-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com 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=ham autolearn_force=no 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Remove frac_lsb, frac_lsbm1, roundeven_mask. Compute these from round_mask in parts$N_uncanon_normal. With floatx80, round_mask will not be tied to frac_shift. Everything else is easily computable. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- fpu/softfloat.c | 29 ++++++++++++----------------- fpu/softfloat-parts.c.inc | 6 +++--- 2 files changed, 15 insertions(+), 20 deletions(-) -- 2.25.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index ea7ee13201..741480c568 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -563,9 +563,7 @@ typedef struct { * frac_size: the size of the fraction field * frac_shift: shift to normalise the fraction with DECOMPOSED_BINARY_POINT * The following are computed based the size of fraction - * frac_lsb: least significant bit of fraction - * frac_lsbm1: the bit below the least significant bit (for rounding) - * round_mask/roundeven_mask: masks used for rounding + * round_mask: bits below lsb which must be rounded * The following optional modifiers are available: * arm_althp: handle ARM Alternative Half Precision */ @@ -575,24 +573,21 @@ typedef struct { int exp_max; int frac_size; int frac_shift; - uint64_t frac_lsb; - uint64_t frac_lsbm1; - uint64_t round_mask; - uint64_t roundeven_mask; bool arm_althp; + uint64_t round_mask; } FloatFmt; /* Expand fields based on the size of exponent and fraction */ -#define FLOAT_PARAMS(E, F) \ - .exp_size = E, \ - .exp_bias = ((1 << E) - 1) >> 1, \ - .exp_max = (1 << E) - 1, \ - .frac_size = F, \ - .frac_shift = (-F - 1) & 63, \ - .frac_lsb = 1ull << ((-F - 1) & 63), \ - .frac_lsbm1 = 1ull << ((-F - 2) & 63), \ - .round_mask = (1ull << ((-F - 1) & 63)) - 1, \ - .roundeven_mask = (2ull << ((-F - 1) & 63)) - 1 +#define FLOAT_PARAMS_(E, F) \ + .exp_size = E, \ + .exp_bias = ((1 << E) - 1) >> 1, \ + .exp_max = (1 << E) - 1, \ + .frac_size = F + +#define FLOAT_PARAMS(E, F) \ + FLOAT_PARAMS_(E, F), \ + .frac_shift = (-F - 1) & 63, \ + .round_mask = (1ull << ((-F - 1) & 63)) - 1 static const FloatFmt float16_params = { FLOAT_PARAMS(5, 10) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index e05909db8c..a026581c33 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -145,10 +145,10 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s, { const int exp_max = fmt->exp_max; const int frac_shift = fmt->frac_shift; - const uint64_t frac_lsb = fmt->frac_lsb; - const uint64_t frac_lsbm1 = fmt->frac_lsbm1; const uint64_t round_mask = fmt->round_mask; - const uint64_t roundeven_mask = fmt->roundeven_mask; + const uint64_t frac_lsb = round_mask + 1; + const uint64_t frac_lsbm1 = round_mask ^ (round_mask >> 1); + const uint64_t roundeven_mask = round_mask | frac_lsb; uint64_t inc; bool overflow_norm = false; int exp, flags = 0;