From patchwork Tue May 25 15:06:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 447320 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp4435169jac; Tue, 25 May 2021 09:36:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNLmogReIBw6lbd+TiHQevzMucq9L2/j4gLSxX83ubvDAguv5u5sgXOnaUW6/7op8fPvuI X-Received: by 2002:a17:906:bc98:: with SMTP id lv24mr13001140ejb.297.1621960606170; Tue, 25 May 2021 09:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621960606; cv=none; d=google.com; s=arc-20160816; b=G2jsrfUY/pznf+a4LlhxceHf8naqewWGfRckG+rI859D91aRFN38LFi/7FkuhA2n69 /mQe6pGWQRAI891d/n6OnemSQYgg74fmGif9pjnDnkhmRbIH+IawjMQtm1Jf2JU2bc8p 3/NjFFjtuwNzIvevImpA7hOSWWMsOrvZV4EQ0q7KsgQPpHUgmaMZQICpZ2N1h2JD3lDB rTNf0NQe4BZjD1KBICuOyvMFg8LjEJt1Wp4hUDMPTBeh70Cgek9I723dvlF1dKV8IFmb Q9bm+aVef+XfZEStfiPBdKuVDFj13tsIvi+B2Iy6MzxtDRFyB8keWQIcHu0NtNkWWmzh 7ovg== 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=2BYof1ybjsIxHUNZfvumVsH9xGhAIK1VpElG81z2ZqA=; b=cy2so44MJt7SzNNnPY+UHqzKuPyInEQNceQmM9VKl1gU3Zis1T8cLvu/oe9NXAvsBQ Jkb1YVkut0s4r84Ms133FfwqmNa3Tm4KF+BrjdC89nwNAnniP54uTEXpcvyrS1H722He P4Mb6jX1qDKUVHxq3EgTw+/EiiYD8CvD3ykMdgqyaEqZ4EU306nerDaFjy2e2cqZQsgu R9GCcmd0mgy86Oh/mkA6lIwecT9JE0dE93mzYG9vs4mPEWuA17ymRoPAddPcpIIsN2pR QvIegt5VfvaL4Qgoees8zTDCzUvJfDzHJC2NgnutPHKmfVAi449iij15BAeVMIa1HJ+e APYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mfKKUqZv; 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 kl25si16295693ejc.370.2021.05.25.09.36.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 May 2021 09:36:46 -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=mfKKUqZv; 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]:50144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lla2v-000307-3t for patch@linaro.org; Tue, 25 May 2021 12:36:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llYed-0001y8-Cp for qemu-devel@nongnu.org; Tue, 25 May 2021 11:07:37 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:34505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llYeN-0006iK-DE for qemu-devel@nongnu.org; Tue, 25 May 2021 11:07:33 -0400 Received: by mail-pf1-x42c.google.com with SMTP id q25so5792020pfn.1 for ; Tue, 25 May 2021 08:07:17 -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=2BYof1ybjsIxHUNZfvumVsH9xGhAIK1VpElG81z2ZqA=; b=mfKKUqZv3XHLRQVOUm9AhbVg/jlijc0xkOEXg5xQfsHfXtTqIZ3sY/uydRS0jvtjiD T2b0pdzwrSiY1av82z2pAI+bqRvPEC+if+DuUIrjLWSZhyAhnsUGM6XqpM9lXJa3dQTW vYksNrPyzqrKGK+rJA6lUjwAOMj9yiPDWjayPADvBrq1xnUEGNrNvF1XcIyRukWFM0Yq eJzNtLjm+BPuhkEpx3JnuJdMHPECCdOuujTR5+LRvjigVKDs2yfx3FqomfUBQ6HdX9OQ WagZWz8P3LJOrCFzrxA61n+Fs94GgvXTsNL5FcBJyZ7ig0nGZS19mAGfuOd5VwhuqvbQ J7XQ== 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=2BYof1ybjsIxHUNZfvumVsH9xGhAIK1VpElG81z2ZqA=; b=VcdZ9Fp+VWpQ/sdu0CHkG6O2h1hyGfbV1G3ckXtLr/srzQjk7GGYc749f9ZYhlmLPq swWlWh6uxWxjTcWTJmULk5PRQXobb9YZuaLGkXDUr4ZoEwAUQlS+e81+FzagPnNblt72 cIuKEEVQPseqvpUfG7axREvkjNr67TIzOc7amdQqSfm2ugYemge44WQRhC2ovsZVRvZG UkdxDhq+qAunfuemNCbOpXPtuql4wwuM7DN9w6omYspEujouSKwTZbH5tH0zwq0xAJSk GRjLkllq0HHLEF621yxH7b+yHfClwMjwYoounEJt61qOf2qsW2+5UpC3Ih5mNF3az150 uu4Q== X-Gm-Message-State: AOAM531XJRtLLo70sv6lRfAS+WWCgoHFUcUIoWZO0Gxc/MUWUXnsm3n3 9keXwdxme4wT/KGRqWZLZ09u8GtyRtCRzw== X-Received: by 2002:a62:148e:0:b029:2e4:e5a5:7e33 with SMTP id 136-20020a62148e0000b02902e4e5a57e33mr22350849pfu.9.1621955236880; Tue, 25 May 2021 08:07:16 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id z19sm2231943pjq.11.2021.05.25.08.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 08:07:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/28] softfloat: Convert floatx80_mul to FloatParts Date: Tue, 25 May 2021 08:06:52 -0700 Message-Id: <20210525150706.294968-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525150706.294968-1-richard.henderson@linaro.org> References: <20210525150706.294968-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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: alex.bennee@linaro.org, david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- fpu/softfloat.c | 76 +++++++++---------------------------------------- 1 file changed, 14 insertions(+), 62 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 073b0440eb..2f2d1e50f7 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1944,6 +1944,20 @@ float128_mul(float128 a, float128 b, float_status *status) return float128_round_pack_canonical(pr, status); } +floatx80 QEMU_FLATTEN +floatx80_mul(floatx80 a, floatx80 b, float_status *status) +{ + FloatParts128 pa, pb, *pr; + + if (!floatx80_unpack_canonical(&pa, a, status) || + !floatx80_unpack_canonical(&pb, b, status)) { + return floatx80_default_nan(status); + } + + pr = parts_mul(&pa, &pb, status); + return floatx80_round_pack_canonical(pr, status); +} + /* * Fused multiply-add */ @@ -5866,68 +5880,6 @@ floatx80 floatx80_round_to_int(floatx80 a, float_status *status) } -/*---------------------------------------------------------------------------- -| Returns the result of multiplying the extended double-precision floating- -| point values `a' and `b'. The operation is performed according to the -| IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*----------------------------------------------------------------------------*/ - -floatx80 floatx80_mul(floatx80 a, floatx80 b, float_status *status) -{ - bool aSign, bSign, zSign; - int32_t aExp, bExp, zExp; - uint64_t aSig, bSig, zSig0, zSig1; - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { - float_raise(float_flag_invalid, status); - return floatx80_default_nan(status); - } - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - bSig = extractFloatx80Frac( b ); - bExp = extractFloatx80Exp( b ); - bSign = extractFloatx80Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FFF ) { - if ( (uint64_t) ( aSig<<1 ) - || ( ( bExp == 0x7FFF ) && (uint64_t) ( bSig<<1 ) ) ) { - return propagateFloatx80NaN(a, b, status); - } - if ( ( bExp | bSig ) == 0 ) goto invalid; - return packFloatx80(zSign, floatx80_infinity_high, - floatx80_infinity_low); - } - if ( bExp == 0x7FFF ) { - if ((uint64_t)(bSig << 1)) { - return propagateFloatx80NaN(a, b, status); - } - if ( ( aExp | aSig ) == 0 ) { - invalid: - float_raise(float_flag_invalid, status); - return floatx80_default_nan(status); - } - return packFloatx80(zSign, floatx80_infinity_high, - floatx80_infinity_low); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 ); - normalizeFloatx80Subnormal( aSig, &aExp, &aSig ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) return packFloatx80( zSign, 0, 0 ); - normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); - } - zExp = aExp + bExp - 0x3FFE; - mul64To128( aSig, bSig, &zSig0, &zSig1 ); - if ( 0 < (int64_t) zSig0 ) { - shortShift128Left( zSig0, zSig1, 1, &zSig0, &zSig1 ); - --zExp; - } - return roundAndPackFloatx80(status->floatx80_rounding_precision, - zSign, zExp, zSig0, zSig1, status); -} - /*---------------------------------------------------------------------------- | Returns the result of dividing the extended double-precision floating-point | value `a' by the corresponding value `b'. The operation is performed