From patchwork Tue Dec 24 20:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 853261 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp4083803wrq; Tue, 24 Dec 2024 12:14:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV1yRsh4vVOlZipIIR+KHBIIc/4mySsqTzVIj1ZAwI3iSXfN0f5zqoo8ZhLO3cujvT2FTSCdw==@linaro.org X-Google-Smtp-Source: AGHT+IFn0tLN2FbSvPyMwLw2pVS3fzLPDpuE5z+nkLsH21ILlSk7WHrPjh+13VzxbdSqg15TJ2QU X-Received: by 2002:a05:6214:2264:b0:6d8:ae2c:503a with SMTP id 6a1803df08f44-6dd233af4f9mr274229026d6.48.1735071287888; Tue, 24 Dec 2024 12:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735071287; cv=none; d=google.com; s=arc-20240605; b=WF7vH1cVXttYXOkh1uH3qlCtyYCkFVzpTvMjZdlMt2nSfKmFtE02mud5umSKBNOfWt Q2KjaOZmDXNEGmpOuW1EPIx3R6TzM3G4HiTbB89rU9NLwz0pXFRkfZH9beMUscWEzTUN ctkFovd3n/f0fJINDbuX3ZiAnu8TwvFvgIgsZyTBKtKtIDpfA8fsQT9dfJu+gmgp4cFV 70DcWM6vG/ApYvNXM0sftzVf96eHIWd1HLcHxbtQVJ9q9XUhY26T87G1FZ3//JsVW6Rr fho1791SI3A9gZ2e6I/HdT+DkOYD1Gid+laUPrS6tQ/kKIF1m23XcfYtklgPp8wMCDLo SKXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=zmgwYYyv+juXwg/CgaDAXGKo2B+5k9ACWJHCK3pXUJ4=; fh=erpJr+t1J1nk7LsZaPa1TvOu4e//VqKoadf7h5wHEDQ=; b=DvPJLP9wXFp5z8fTOdsGutALww3OEBPwPxkU1hz2C2rfG89yDRbIMzpWzxXQUlVOEJ nm6ru+ts9Rlq86MFvozZG37KQPcVfcVQhh4NlOL5RKMAaQSlf9mTYYWRhFem1XYzpesl ZuE8yVEhWCiXnENfZsXp1KuFHPUZxJdGMTIz54ltROzD3fhIi3VOWR43iXDEjlOcOL23 d8jd+V9AOpbJqjWdnUKcEw/4xbNRfasKCIvkphT519a1uYOOddcurzzleUpjB/BJnlWz Dg2HoAO8OL2QYfpSAb8ayGNaQFfGnGeCDF7z1UqX/f4wsXtVmJ2jUbq4oVnhPB+Wca+P fFdA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HL7R1URW; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18138e2bsi157950436d6.178.2024.12.24.12.14.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Dec 2024 12:14:47 -0800 (PST) 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=HL7R1URW; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDz-0001eE-T7; Tue, 24 Dec 2024 15:09:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQBDg-0007Wn-Qr for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:33 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDf-00030k-0U for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:32 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21675fd60feso73587425ad.2 for ; Tue, 24 Dec 2024 12:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070969; x=1735675769; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zmgwYYyv+juXwg/CgaDAXGKo2B+5k9ACWJHCK3pXUJ4=; b=HL7R1URW8hSYKtS8mqC7XPJm3HLZ53Ggibg5hmtTiG9DAUnzfRO0iU9khoiSQc4hd/ hZyFzx3aoyThexULHkC7cvtJiyUs8mFxW+X49ulvEwmpFmBchctfWVbozd1Njf1LODyw 7L2Wc3oT6rGqlQMgltMDDEeejCHpcbRWlVf3PmXjytR6k6R5xhh7QCbOrvjcOjmFCc6G iVMXIdv2+W1yrzwQ9LysXOdplZezbq6LgjgQVTunz04ZtNBGKgW8Ulw29PUIvAtcy/SJ ItBjMotDVWDiA4a1sHEuX3kx79w+p4A+xDKK8HbnIuvOUrOXCk0dcznY0N0FB06garrE h3AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070969; x=1735675769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zmgwYYyv+juXwg/CgaDAXGKo2B+5k9ACWJHCK3pXUJ4=; b=bUCIX/elFqyw1NGyrEEkBVzOzW1q1IXpk5McZ0HZDBGZZt4I52odqV25/CSSxE6Q2k moe9ovb9gwR3ERDzxg8hbbjUwIUkvBib/mwtNMo9vkJYoaWYVulkmTpMa6ljwGh5DCra dU7Qnl2xqSHiFmP9T0UMrzXEPt0whb9HgVluOqSRemSrU43qVQDXX/h8fVmGqvO+bGlP MX2FtYTH4EA+RxxGgUuRTXRMPZ/uOzHhpSwDQARh5zxCqDNHra+cZmDYwKpjuydm3qpp gbfy/46r2OV8WS9bNBRHAC5Q6qN0OToZC3HY8f+5tPLhDjfqSfB9M4bDALGBsqcZ6XGS Whmw== X-Gm-Message-State: AOJu0YxT66L0OjJCJFWQmkZ1P6cQ2ghN3ZLdV6wW+0h4KeD+5TBea5NF CusoX8hkHsCMPAls4CzqWRQ6P83SAcY/+btcZxv5e1xTaqxYWrfvRrFoUcx0rxkFB3CRNsqxmdc vT9o= X-Gm-Gg: ASbGncuYRURORK0eSSBDvjkuasB1wMc1ivOmi/9WyhDHaiUidN/hS1j4QBu0JMJR0im bFGUMsLU4UbMDaT7CTFrWDBG6mq3ap1JfExvrlPGdUlnJkheRPP2WoYpwHDX2zwz0ybTzyLLvdF 9h10i8mPbb4OQ1IX7dlbLU2ZsKG06aGi8UD2cb6i610YX4eK2jUmpBkm1ioZ10At5rQG2NYDLVY 9XuifzvAWVGy8HHdhndqtOz+y2tnB5tZUyAF/KPR91yr2m07QCfErrzHE1E9/prJRpSPeoXH9Ey ZKm+XAgN+ChzndBBvch4ItEUbA== X-Received: by 2002:a05:6a20:7289:b0:1e0:d4f4:5b39 with SMTP id adf61e73a8af0-1e5e04a0ee8mr31050261637.24.1735070969558; Tue, 24 Dec 2024 12:09:29 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 69/72] target/hexagon: Remove Double Date: Tue, 24 Dec 2024 12:05:18 -0800 Message-ID: <20241224200521.310066-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This structure, with bitfields, is incorrect for big-endian. Use extract64 and deposit64 instead. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.c | 46 ++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 2a8f72fee3..ddc793fe14 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -43,39 +43,29 @@ #define WAY_BIG_EXP 4096 -typedef union { - double f; - uint64_t i; - struct { - uint64_t mant:52; - uint64_t exp:11; - uint64_t sign:1; - }; -} Double; - static uint64_t float64_getmant(float64 f64) { - Double a = { .i = f64 }; + uint64_t mant = extract64(f64, 0, 52); if (float64_is_normal(f64)) { - return a.mant | 1ULL << 52; + return mant | 1ULL << 52; } if (float64_is_zero(f64)) { return 0; } if (float64_is_denormal(f64)) { - return a.mant; + return mant; } return ~0ULL; } int32_t float64_getexp(float64 f64) { - Double a = { .i = f64 }; + int exp = extract64(f64, 52, 11); if (float64_is_normal(f64)) { - return a.exp; + return exp; } if (float64_is_denormal(f64)) { - return a.exp + 1; + return exp + 1; } return -1; } @@ -346,6 +336,8 @@ float32 infinite_float32(uint8_t sign) /* Return a maximum finite value with the requested sign */ static float64 accum_round_float64(Accum a, float_status *fp_status) { + uint64_t ret; + if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0) && ((a.guard | a.round | a.sticky) == 0)) { /* result zero */ @@ -455,22 +447,16 @@ static float64 accum_round_float64(Accum a, float_status *fp_status) } } /* Underflow? */ - if (int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) { + ret = int128_getlo(a.mant); + if (ret & (1ULL << DF_MANTBITS)) { /* Leading one means: No, we're normal. So, we should be done... */ - Double ret; - ret.i = 0; - ret.sign = a.sign; - ret.exp = a.exp; - ret.mant = int128_getlo(a.mant); - return ret.i; + ret = deposit64(ret, 52, 11, a.exp); + } else { + assert(a.exp == 1); + ret = deposit64(ret, 52, 11, 0); } - assert(a.exp == 1); - Double ret; - ret.i = 0; - ret.sign = a.sign; - ret.exp = 0; - ret.mant = int128_getlo(a.mant); - return ret.i; + ret = deposit64(ret, 63, 1, a.sign); + return ret; } float64 internal_mpyhh(float64 a, float64 b,