From patchwork Fri May 15 18:47:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186860 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp686035ilb; Fri, 15 May 2020 11:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgh9eKvdIXsmg60O3Mcg2dLyPPsBQdtvOh+PU/xpanyhTWl0ugwozbyxn62UuooNgyCgMQ X-Received: by 2002:ac8:6f2f:: with SMTP id i15mr5041697qtv.53.1589568495459; Fri, 15 May 2020 11:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589568495; cv=none; d=google.com; s=arc-20160816; b=KEhI0q8wJ+2/p7sO03sJPrFbyXx01zaQDYNe/JV0G5TGb+3HqG6XKFtpXECv0QIqxx Nu/huMKQFNXkOAvymx2qItj0xx/7RpIgRXPpkU+X0kUjN9IwxKWstTWLO7aI5kzmc9n4 6gtAW54zyWl2r2YBJ30jbpgyt3lfrlC59/ikWcnAGRAV4S7cfo33NHpL4kbGJdgsj7BO xh02or3scv8CdgHVWC23m0h/TCsj6lnGTRKjBPH1w4hy73hm6QrkDWGjNrmIN718WF/y tsT3lphvCNXzHPKrn2yG5qMFjFlTCHnxkLgcD2vvwT4+MSL7luaS/i/O/3R83e37Pz1R C3AA== 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=cMmDD1w5euAwfTOHzuv67r0X2MSI19HIQQ5/Y6AnMtU=; b=xNJl4COZrvVAHYHlv7rgn5hZ0RF6+UNI9ZT3LBMkLflv+cOCpg+EUC30VK6PFmvZWp o8sIJpERq968Ywg0gZ/Dmrl0yMHUrRj2t0Z41rR6QbVFqsXmB9KUsiaRDnbD5ksbIlYV WUr/G+xpWgAX6QgLgwPwIR6OklWIDvAbyaNpHTDxvt54jdf9TWuSkS0CU41C8cAKrBJs RiIcgp6uOIuWBg9mTyP0hrKBxbf5CkU7ECqBWUlkxR7JouBYBq8Dhj7IeTliLW+bdxkS XwvoPPcfDm27lJpRAnx2XZ96Pxreb7rmkDtelgGMfroJoy/Nf4t2HBY6VHFomoF73biL erlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WMeP33kb; 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 l20si1548540qvz.198.2020.05.15.11.48.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 May 2020 11:48:15 -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=WMeP33kb; 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]:42026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZfNW-00086L-UF for patch@linaro.org; Fri, 15 May 2020 14:48:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZfMo-000839-No for qemu-devel@nongnu.org; Fri, 15 May 2020 14:47:31 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:36588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZfMn-0005xs-QT for qemu-devel@nongnu.org; Fri, 15 May 2020 14:47:30 -0400 Received: by mail-pg1-x542.google.com with SMTP id c75so393273pga.3 for ; Fri, 15 May 2020 11:47:29 -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=cMmDD1w5euAwfTOHzuv67r0X2MSI19HIQQ5/Y6AnMtU=; b=WMeP33kbglvSe6Z92DcVtJdWXUK7zTT51QmEKEhoOL/RppYemcNQR+0Mpm+NOfuftg +nV4DJfRT97m/sLsu6jjVNhGPQEmhHQS2xrCDhE57IYW/+VPEkCSEKsTRr5NlXAdlpDB H2ZeO0Z/kEmgcq2BHEdNFrAQxyzbJmLwTB2UoSbk4YDisE5CfXkLJORMQVxGBCIuTJ2V 8UNHWY2brM5m/ARpvQO1U/Cpn8YEhzR8xTjmx8Me7nI90RXE8to0PrWR/hN2rTyPUdwm lw/ijzK4+xJ202PTBWXVf1zm2Iz+M+bwv41+ho2PZB9WdE5mpVuBVmz8N7+5SLZLoANs BoYg== 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=cMmDD1w5euAwfTOHzuv67r0X2MSI19HIQQ5/Y6AnMtU=; b=q+jwCZtDkGTsWhic7hXSePpdcFm692j6VkUJpsohhgwygdUz74VwcCoKL318fGYvt4 S0WRcDLPHfDA1LRIkOWWqVCXcEP9/YuMqMxmM2qnvUKFSAwX9rlirElpCSVTbXYrpY3z 1+kR8i7s7avdecUyyuBMB1PgGr3VtPY5mv+RhabuFmGlvMB4uE0ZQexcBJe5OVdezngv BwUZONodXRkJ9VP+zYzv4fCCRNbcc6YS9fRPKNge6UBSaqTiOIwUFH+xBLinbGEypUlO cyysuo0ZYgPOWh7i1TFn9xFl01k6dbmcsDHS3udQ/8R9tuMr6tZe1JBIoYWXrkr8zx0e oiEg== X-Gm-Message-State: AOAM531ZQ5KPSZeSn/1laRA2T7BK3c/mm1JcDq1BgLmbgIWkk4zASnqF e7uiGX4dylsjFtsAHt2QsG6zaMXAnfE= X-Received: by 2002:a62:754f:: with SMTP id q76mr5428030pfc.14.1589568447897; Fri, 15 May 2020 11:47:27 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id u73sm2743630pfc.0.2020.05.15.11.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 11:47:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 3/4] softfloat: fix floatx80 pseudo-denormal comparisons Date: Fri, 15 May 2020 11:47:21 -0700 Message-Id: <20200515184722.31182-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200515184722.31182-1-richard.henderson@linaro.org> References: <20200515184722.31182-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: peter.maydell@linaro.org, Joseph Myers Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Joseph Myers The softfloat floatx80 comparisons fail to allow for pseudo-denormals, which should compare equal to corresponding values with biased exponent 1 rather than 0. Add an adjustment for that case when comparing numbers with the same sign. Signed-off-by: Joseph Myers Message-Id: Signed-off-by: Richard Henderson --- fpu/softfloat.c | 7 +++++++ tests/tcg/i386/test-i386-pseudo-denormal.c | 4 ++++ 2 files changed, 11 insertions(+) -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6094d267b5..c57f72e3a6 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -7966,6 +7966,13 @@ static inline int floatx80_compare_internal(floatx80 a, floatx80 b, return 1 - (2 * aSign); } } else { + /* Normalize pseudo-denormals before comparison. */ + if ((a.high & 0x7fff) == 0 && a.low & UINT64_C(0x8000000000000000)) { + ++a.high; + } + if ((b.high & 0x7fff) == 0 && b.low & UINT64_C(0x8000000000000000)) { + ++b.high; + } if (a.low == b.low && a.high == b.high) { return float_relation_equal; } else { diff --git a/tests/tcg/i386/test-i386-pseudo-denormal.c b/tests/tcg/i386/test-i386-pseudo-denormal.c index cfa2a500b0..acf2b9cf03 100644 --- a/tests/tcg/i386/test-i386-pseudo-denormal.c +++ b/tests/tcg/i386/test-i386-pseudo-denormal.c @@ -20,5 +20,9 @@ int main(void) printf("FAIL: pseudo-denormal add\n"); ret = 1; } + if (ld_pseudo_m16382.ld != 0x1p-16382L) { + printf("FAIL: pseudo-denormal compare\n"); + ret = 1; + } return ret; }