From nobody Mon Nov 23 04:52:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1791861308; cv=none; d=zohomail.com; s=zohoarc; b=gypqcWjPxwSikaQfpmGdbwqSNTHuTL5A/XiuwnPJkggK8d0oP+ddD7hR+V07gwqn1EvcdTcgunStMnGNVjG0+nDjuoyS85nu2YL4/Lg3iNwspVGTDbhH9tQ1lmwqR2Fn+n2K6cC1EXy6mne5ccyA6cY5fGD+xGQJToaVOdJf7zI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791861308; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=68hSqH7Obq3adXkxpWVwEtldVIGLDOHAUecZc7LjqTI=; b=AoTKbbC3gS+jXIiquS4lVhzmQBsL9vt/P9RsokdSNuEWkksbsToCfHuixeeHsh5KtvG3L0Cjp5l7ySWVQuQwe+qKQHAsbTeHk8l1ih2PTBuAIvtqzmKiNsgtUaS3Us3yP3MKmOzsM/pRmc9n1bsxOMw3yELRJP7OWhiFbpLbsV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17918613083712.617998931322745; Mon, 12 Oct 2026 20:15:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGSyF-00007S-Pk; Mon, 12 Oct 2026 23:14:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGSyD-00007H-IX for qemu-devel@nongnu.org; Mon, 12 Oct 2026 23:14:29 -0400 Received: from mail-yx1-xb134.google.com ([2607:f8b0:4864:20::b134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGSyB-0003Ul-R6 for qemu-devel@nongnu.org; Mon, 12 Oct 2026 23:14:29 -0400 Received: by mail-yx1-xb134.google.com with SMTP id 956f58d0204a3-677d35fd1d2so2268538d50.1 for ; Mon, 12 Oct 2026 20:14:27 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-679354e2c11sm4253965d50.3.2026.10.12.20.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 20:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791861266; x=1792466066; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=68hSqH7Obq3adXkxpWVwEtldVIGLDOHAUecZc7LjqTI=; b=KUsCHfRhSGK0n3LwTrYofyTihCQBWbWjpxmmxv7cibKD41z9QODWAbkcKi1Rd49Wa2 ciS+iEAw9TtS3M9jGWwnwvt2b12L2xD0nHcnji6HCDuoxKHg7Mf+ITqwAWlqrSXyqdTC Mn0jbGmS3LAoMqVo3mLW28AMbiZa9F5SUMq+7sj3reYBKUwEmUZTR7bRPOBU8yu7sR/9 orMlfRt3PdqAT+GEunFCdlAXSekNqXxYnZWf/6GCybBi+YGcXNj1rVpHnIc7vI+45nuv QqZGkzb1fDFYpAUQtGh8GnMhMIW6Gj+ztIgaSqStEtao10Wrglh2gpPP18OQT77avBvo gsxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791861266; x=1792466066; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=68hSqH7Obq3adXkxpWVwEtldVIGLDOHAUecZc7LjqTI=; b=BJk4g8x6Njr8ZoZMN/yNX5vugP4/E/DA88RED0LOZNJtWCk8SDd9SgBwOSiBG1SqtJ wgH6suHcDpy5/irEcAgQ8y/tqHDUn6sibE4eC2Jyv2mAgCK0tvoYVBAZrpUx+6bjbwYH l3tyXlweskDvktHJM3/Sg3KRijTTW+MEC0Mv6Riod/trJkBzbf+DFgsN6p/eX+9ZmK4z aaN4smfebNDWCxV6BKSdBbpPshZ4GOZk3qll42qKubjT98Txk/6ri1ESRVVVwsghbkrU Ne3OVyXD61Y6ugXIdNfD6WXZm/sV4+N12vZZ2hjgFEWe74EhdmqCwvChDmaKmLTIkhRG w5YA== X-Gm-Message-State: AFq9FYIL30Afn8zelMk69fH9P1XCmdq0qaOWmS/8jC7NUPCpciZG/IIo ReHkPULnohMhytHDqs1JfTtSLZdZTwkjktb42q131tk//eew73vBrSYf4os9Fw== X-Gm-Gg: AYBFou1WWVmaeJQMQ3w3yTF7uD80qonNwDv4bL5vlyEHTyp33nNGTMAFkIHRxFESiPx UNbDDCftkjLxbL35bzmtoEhcIsQmjVws29LGy3rvF248LpDxL840RjoQ9WVpc2BVpI1PbtfUNxQ 9fI4KphGhk/QD0YYjXVRXTpQKubXT+jD01e+ySWFaKp63iy4+9bc2AMKZfdcv16QazGDIpJqDv7 k+L44q67DJZJK+zbHfBfcvpECheMrxCtNoRCaUGwOUnm/ObgsIol8MkTLqSmMfRA3G4uLhR183/ HA02eaGX3PLbApSxEtvWJECRVlUnlxsoF6VtqC9P8sVcvXTiN9zsVHRggwpMG/WUFelO30cRr8f MTp2G4rGPIYYTtStcHX/17arZiUrp1qJJH/0SEhPlNIl5/8fueqZaxrNVm8P5H38hflZ4RlzYT0 f1FjfvUxn2WK+RMMeU+V+iBRABEC+bI5HUmgF5HtYRG6zY5LN2eJ5XWjS8j8jnBsE6NyQfKsqXH KAhNin4v64v2w/t50O2Q8wvCfWqPAs5v8UWYDp7qud9yaHWzaIErlyq X-Received: by 2002:a05:690e:1513:b0:66d:e3d:59c6 with SMTP id 956f58d0204a3-6793600cd0dmr2982346d50.22.1791861266128; Mon, 12 Oct 2026 20:14:26 -0700 (PDT) From: Matt Turner Date: Mon, 12 Oct 2026 23:14:22 -0400 Subject: [PATCH 1/2] target/alpha: Record masked exceptions in FPCR for /S insns MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-alpha-fpcr-status-s-v1-1-bc7efa6d5609@gmail.com> References: <20261012-alpha-fpcr-status-s-v1-0-bc7efa6d5609@gmail.com> In-Reply-To: <20261012-alpha-fpcr-status-s-v1-0-bc7efa6d5609@gmail.com> To: qemu-devel@nongnu.org Cc: Richard Henderson , Helge Deller , Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2097; i=mattst88@gmail.com; h=from:subject:message-id; bh=4yaCMwkIG1VyvG/pVD4tFhFkyK89eVVf1KQZhpRKJgg=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLLOLuI90Ln036MZP8xDV7s86Xm47F/okxUGNQ/E9+rFM Mt/d+sU6/jIwiDGxTBTTJElbr0iy6y2HUt9Tkv/gpnDygQyRFqkgQEIWBj4chPzSo10jPRMtQ31 DIEMHaN4iJweg0ZmcXFpapFuWkGRQ15+SWJJZn5esV5+QWpeQXqBXlpmWklGRn5RcSrQCL281BJ TV0c3I0MDE0tHCzMnC0dTE2dnJ0MnN0dHZ1cnI0tzEwNnS0cTV0tzBi5OAZhr0mcxMmx+kJ996+ vUpac0nx93/Oc3lU1q45utweqT396cv0t3XRgPw19xr6zrRS/ajJ/1xAdXyF07GN+yY0ojm8EOj ecbns5OX84FAA== X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b134; envelope-from=mattst88@gmail.com; helo=mail-yx1-xb134.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1791861309698158500 The trap qualifiers (/U, /V, /I) control whether an exception traps, but EV6 still records every exception in the FPCR status bits. Commit 471d493047 ("target-alpha: Set fpcr_exc_status even for disabled exceptions") made helper_fp_exc_raise follow this, but in helper_fp_exc_raise_s it only added a second "exc &=3D ~ignore" and left the mask in the initializer, so for insns with software completion the masked exceptions still never reached env->fpcr. The most visible effect is on inexact: the IEEE-mode code generated by gcc -mieee (e.g. ADDT/SU, DIVT/SUD) has no /I qualifier, so FE_INEXACT was never set. Many of glibc's math tests fail because of that, and the narrowing functions such as f32addf64 return results 1ulp off because their round-to-odd step depends on inexact. Record all exceptions first and only then apply the ignore mask, as helper_fp_exc_raise does. Which exceptions trap is unchanged. Fixes: 471d493047 ("target-alpha: Set fpcr_exc_status even for disabled exc= eptions") Signed-off-by: Matt Turner Reviewed-by: Richard Henderson --- target/alpha/fpu_helper.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/alpha/fpu_helper.c b/target/alpha/fpu_helper.c index 529eadca9f..643ce641e8 100644 --- a/target/alpha/fpu_helper.c +++ b/target/alpha/fpu_helper.c @@ -86,9 +86,17 @@ void helper_fp_exc_raise(CPUAlphaState *env, uint32_t ig= nore, uint32_t regno) /* Raise exceptions for ieee fp insns with software completion. */ void helper_fp_exc_raise_s(CPUAlphaState *env, uint32_t ignore, uint32_t r= egno) { - uint32_t exc =3D env->error_code & ~ignore; + uint32_t exc =3D env->error_code; if (exc) { + /* + * The qualifiers can suppress the raising of exceptions, + * but real hardware still records that they occurred. + */ env->fpcr |=3D exc; + exc &=3D ~ignore; + if (!exc) { + return; + } exc &=3D env->fpcr_exc_enable; /* * In system mode, the software handler gets invoked --=20 2.55.0 From nobody Mon Nov 23 04:52:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1791861318; cv=none; d=zohomail.com; s=zohoarc; b=cZ0J7zGY9jpP5mRAzoWzNm20w3UvE7RQdABA4FQDBrfwqhJGeKHMe5kS2vwla8CHrbnNvoMVQU43+HFb2w4zg0PjlRrDBCfQ3vnfs6WWOwr0LcbHzvwyDFYOuM/HYsuefDd00FjmE5e/Yy1sPwPHdBuZ2psAW79LEzqcyO7DWPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791861318; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L6sU5VMmStegCn9Y0sx6fXu7t/rJE2at+L69jLeCSZk=; b=QKJU1yJXiAYXZhxWPzCWRMk0YDNLIWJIBI9LSD5180+0Q7Uv3FB2jcohAsh5RSvwCc+L3gbnokChKM1rXIYXodgLEvvawxbz1cGe8E1o5FXz0XiNWJzcxrMW1OOSFCBJikEZ+bxcLzleEcGQfO2txhHFfEz3E+wP+F66nVmFA3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791861318900429.2306172172407; Mon, 12 Oct 2026 20:15:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGSyQ-00008c-4f; Mon, 12 Oct 2026 23:14:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGSyH-00007r-IS for qemu-devel@nongnu.org; Mon, 12 Oct 2026 23:14:33 -0400 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xGSyF-0003VN-RP for qemu-devel@nongnu.org; Mon, 12 Oct 2026 23:14:33 -0400 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-8ae8607e8afso15686827b3.3 for ; Mon, 12 Oct 2026 20:14:31 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b07f1b8a9fsm39405637b3.9.2026.10.12.20.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2026 20:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791861270; x=1792466070; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L6sU5VMmStegCn9Y0sx6fXu7t/rJE2at+L69jLeCSZk=; b=Rv4rTF0bgNFyIBB6i4sR85/Un++VSrduAsN5w/jkohQFT6c97d1TirIcr5HMugw4L6 DWbwyGGC7iCdKMTaTnVz4/mdLbSmEgrjNXnQpXMDKiuF6c6SSE1B8A9Ch2UoQphepz0E nIxTPqgHFvex+on46tyZO2pNtlqAzjrZ4P7YypKEQyvRLHTkw0Q5YCTy0DIAsR6WZXXF OonBdk35JwOK/JkqnIkiDSvom9Cu0xTUOUU19EXPkW3NJfn2frwxvH65XbW2r5iyGlTA QxzEPXmXWrOII4rEjX5ru4z/IMw7LN+3g7zBvDf6A+ku/622hxHlrDj5fNyrBwwS/+Ah gFkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791861270; x=1792466070; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=L6sU5VMmStegCn9Y0sx6fXu7t/rJE2at+L69jLeCSZk=; b=eCwDPdt5qlxknx1jZv815w1eOmI1IBFEPlFuhxhssixOQOhdMkjQbiupdLxFosY6W/ ghiXe4DOQvs7FukWdlGY5Rpd5SOCf9J0GWPd/M9r8aoqLwzKEeKz7mdyVhsEQzmRaV+2 HCvIxS6EWlGN8T0yxoouS8EWv6nnPt7hcno1atw3SVMwBAeTVkxaPNeXIT4PRlH/Pnr3 KlLZqRC3Ie74hc1Gs0rRrkn5MCh2EY5qpGbsjy8ARP5Krcr67mczkVbWqprotvViWPH5 cMUlivz6bUEeh8u/k7hKY+E0SdGtUZa+1m/7IZYf8kNFJs5r2nv5Aq6vh+F2ijIU/E7O wTGA== X-Gm-Message-State: AFq9FYLvZ6IwFc8qilLzP5JyDpUWZuqKQ0RnKA39mM/csdTukta4D+WP H6RMkM/SJqGrjvbxCeztggRxjmgqreUmqXG8GvGIhTK9Fxi2Yr0r9lysvJX5xg== X-Gm-Gg: AYBFou3B2bBGBAn8/uoVMtp2bR1I84FzB7Ixw83qqEcX8I+8dfrdklfLcchXM/SPfCO gweTniMo1BAfOAbyiCtlT5I2KBk4r6f26Z4sWmqJnBhA87jUKfOgrnrzzORWZDWY1jyjTetqjf3 dCmeCmK6BLxBuiE45Jj8jYXdWR+rPUTzydLOCziMn3fIDyfp5kKY5y8ZvD25d4PCDKxcQYqGJ/Z GGgiIjR7HAoPf9Lh/7H9BMd0TZmMCysezV6ZT7bifMJBOfBGlO6kqbP+YATt08q6tO4cw7JLJ/x CGsEHPo6XCvyqQJmd+LA6QvVbENHUW/ZGonN8Zb595BPVOnuIPnOucKY9m43l745z0pZ5elP85r DokK3qHhWncxtgcnGuNgHAMWO9/F2Z2BV6t8Zd2bZreVchhC++vkFx5YhKF71oQOBHgNho+tnC2 4vkmOEG6R6pI6t9ccfjOljmOulhTJEMDYkloZW5GM4oALm0VYnzHjO2SU8dmMpbpmFA1zmT0sMF tvdPQlDI+LpAD9d/VDe+1d80X/c1KsKd8ZJbzjAt3a1HO+5Pemlm6N2Eg== X-Received: by 2002:a05:690c:7013:b0:8a1:eaa2:36d7 with SMTP id 00721157ae682-8b07ed8e053mr41237497b3.18.1791861270512; Mon, 12 Oct 2026 20:14:30 -0700 (PDT) From: Matt Turner Date: Mon, 12 Oct 2026 23:14:23 -0400 Subject: [PATCH 2/2] target/alpha: Determine tininess from the delivered result MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261012-alpha-fpcr-status-s-v1-2-bc7efa6d5609@gmail.com> References: <20261012-alpha-fpcr-status-s-v1-0-bc7efa6d5609@gmail.com> In-Reply-To: <20261012-alpha-fpcr-status-s-v1-0-bc7efa6d5609@gmail.com> To: qemu-devel@nongnu.org Cc: Richard Henderson , Helge Deller , Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5844; i=mattst88@gmail.com; h=from:subject:message-id; bh=Wzu3aZjeh21N3ckQzpTOPYiQMS1npQA3bMwKXRT7deU=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLLOLuKd0/h45ite1eLXwlL/GPgFDjmbxku8sZU8anOEQ fFt4bbrHR9ZGMS4GGaKKbLErVdkmdW2Y6nPaelfMHNYmUCGSIs0MAABCwNfbmJeqZGOkZ6ptqGe IZChYxQPkdNj0MgsLi5NLdJNKyhyyMsvSSzJzM8r1ssvSM0rSC/QS8tMK8nIyC8qTgUaoZeXWmL q6uhmZGhgYuloYeZk4Whq4uzsZOjk5ujo7OpkZGluYuBs6WjiamnOwMUpAHON3QxGhr6sFW/WRE 6fuPeDw8q54nd95B9uDb7rLqqfWHpb+JSI03lGho2rfPx83beeU/xysoch5j6/cX/uvPzf+1y23 FvnceDxNU4A X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112b; envelope-from=mattst88@gmail.com; helo=mail-yw1-x112b.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1791861319693158500 Alpha raises underflow only if the result it delivers is tiny. softfloat implements IEEE 754 tininess after rounding, which rounds as if the exponent range were unbounded. The two disagree about a result that rounds up to the smallest normal: 0x4p-1024 / 0x1.0000000000001p+0 in FE_UPWARD =3D 0x4p-1024 The binade below DBL_MIN has a finer spacing than the denormals, so with an unbounded exponent the quotient rounds to a value below DBL_MIN and softfloat raises underflow. Alpha does not. glibc marks math/test-float32x-float64-div as XFAIL on Alpha because of this (glibc commit a32db99a38), and under qemu that test unexpectedly passes. Every result that is tiny by Alpha's rule is also tiny by the IEEE one, so there is no need for another tininess mode in softfloat. Drop underflow in the S and T format add, sub, mul, div and cvtts helpers when the delivered result is normal. An insn with a denormal operand is different. Unless DNZ is set it traps for software completion and the kernel computes the result, and the kernel's emulation raises underflow in the same situation: 0x3.ffffffffffffcp-1024 / 0x1.fffffffffffffp-1 in FE_UPWARD =3D 0x4p-1024, FPCR_UNF set That result is tiny whether tininess is detected before rounding, as math-emu does, or after rounding, as softfloat does. linux-user computes these results in the helper instead of trapping, so keep softfloat's underflow when float_flag_input_denormal_used is set. In system mode gen_ieee_input raises the trap before the helper runs. Signed-off-by: Matt Turner --- target/alpha/fpu_helper.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/target/alpha/fpu_helper.c b/target/alpha/fpu_helper.c index 643ce641e8..d902cdd9dc 100644 --- a/target/alpha/fpu_helper.c +++ b/target/alpha/fpu_helper.c @@ -55,6 +55,24 @@ static uint32_t soft_to_fpcr_exc(CPUAlphaState *env) return ret; } =20 +/* + * Alpha raises no underflow when the delivered result is normal. + * softfloat does when that result was rounded up to the smallest + * normal, so drop it, except when a denormal operand means the kernel + * computed the result. + */ +static uint32_t soft_to_fpcr_exc_tiny(CPUAlphaState *env, bool normal) +{ + bool swc =3D get_float_exception_flags(&FP_STATUS) + & float_flag_input_denormal_used; + uint32_t ret =3D soft_to_fpcr_exc(env); + + if (unlikely(ret & FPCR_UNF) && normal && !swc) { + ret &=3D ~FPCR_UNF; + } + return ret; +} + static void fp_exc_raise1(CPUAlphaState *env, uintptr_t retaddr, uint32_t exc, uint32_t regno, uint32_t hw_exc) { @@ -227,7 +245,7 @@ uint64_t helper_adds(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D s_to_float32(a); fb =3D s_to_float32(b); fr =3D float32_add(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float32_is_normal(fr)); =20 return float32_to_s(fr); } @@ -239,7 +257,7 @@ uint64_t helper_subs(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D s_to_float32(a); fb =3D s_to_float32(b); fr =3D float32_sub(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float32_is_normal(fr)); =20 return float32_to_s(fr); } @@ -251,7 +269,7 @@ uint64_t helper_muls(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D s_to_float32(a); fb =3D s_to_float32(b); fr =3D float32_mul(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float32_is_normal(fr)); =20 return float32_to_s(fr); } @@ -263,7 +281,7 @@ uint64_t helper_alpha_divs(CPUAlphaState *env, uint64_t= a, uint64_t b) fa =3D s_to_float32(a); fb =3D s_to_float32(b); fr =3D float32_div(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float32_is_normal(fr)); =20 return float32_to_s(fr); } @@ -304,7 +322,7 @@ uint64_t helper_addt(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D t_to_float64(a); fb =3D t_to_float64(b); fr =3D float64_add(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float64_is_normal(fr)); =20 return float64_to_t(fr); } @@ -316,7 +334,7 @@ uint64_t helper_subt(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D t_to_float64(a); fb =3D t_to_float64(b); fr =3D float64_sub(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float64_is_normal(fr)); =20 return float64_to_t(fr); } @@ -328,7 +346,7 @@ uint64_t helper_mult(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D t_to_float64(a); fb =3D t_to_float64(b); fr =3D float64_mul(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float64_is_normal(fr)); =20 return float64_to_t(fr); } @@ -340,7 +358,7 @@ uint64_t helper_divt(CPUAlphaState *env, uint64_t a, ui= nt64_t b) fa =3D t_to_float64(a); fb =3D t_to_float64(b); fr =3D float64_div(fa, fb, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float64_is_normal(fr)); =20 return float64_to_t(fr); } @@ -429,7 +447,7 @@ uint64_t helper_cvtts(CPUAlphaState *env, uint64_t a) =20 fa =3D t_to_float64(a); fr =3D float64_to_float32(fa, &FP_STATUS); - env->error_code =3D soft_to_fpcr_exc(env); + env->error_code =3D soft_to_fpcr_exc_tiny(env, float32_is_normal(fr)); =20 return float32_to_s(fr); } --=20 2.55.0