From patchwork Sat May 12 00:42:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135609 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1577897lji; Fri, 11 May 2018 18:03:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrEvorqagEjAg/LL2hTLTosMv0Hs+Qea1fWYIwuHEBypiMm80BHwnu4hSqNuZii10VLpCVy X-Received: by 2002:a37:8c82:: with SMTP id o124-v6mr272766qkd.209.1526087001324; Fri, 11 May 2018 18:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526087001; cv=none; d=google.com; s=arc-20160816; b=zr+Pej/NyAmi6rvIz+PN+jFBFS89GoAdLpRXHWqML10RVUZVEpLW/zpqetTlSH/nXp sASishR7b76AqjQL7HpvB8bPG3Tl4h7EcTRK9U63ASjARDDhl2HdJFn3Q24kCYDEFfoc obKXXcDeRkOv/SIw7bR70ecBP//uPNarxRukMHNSzgUpVW4rlhwqihjSCggOIxVZefYp 2AuqN/lV9eMhUSuok9AQqvMVDT5Fk8XLdwIZoWI6pZK6TTEtYjIBTMgzjO95EsAmNJT1 pW4IjX990ZgvzvCk0kjWuDDUokbR80nbuo/EtfPF/Jej5WKRA2SBMD7gJOGftfo10FqS 7cVg== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=CZ8t3rsGP1Vnm6i0MzTN7S1/lYSmU4XX4UAXyYCKUoA=; b=E9wdGyrFwBtv9Erqybdt5W4jrZX8tu1O7Q7n/7lcEkzqsbcKPIS+EXYfDg2EMth52g cFHYmRiNwBlDl+fTsMm1yGaHGy0HpobKuaFljabZz7asvfwT9Be0UUStvUdZXGrBIdKg E/X9teZFlFILTO/r/t+qmo7j8DgqXHuYV1TXH1L0scmNtbYn5Ylmxr7CB8XhJ2lsSCfq fTQf0URp1sDCH1LgTxJc6sukiwbFCs3xKa9BlJLNs+qW2+K8wF6b/2hAiXWDFJetnxV1 8HU8TbqBTXaVe4rSQJr4ET8Mn8maWSKZVTRskCpaHW+RmaeMNoH6u6qM8jJk6wEakyRM M3Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kAv9PJ7Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y126-v6si4020482qka.302.2018.05.11.18.03.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 May 2018 18:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kAv9PJ7Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIwS-0007Ex-Ri for patch@linaro.org; Fri, 11 May 2018 21:03:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIdM-0004dn-Jn for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHIdL-0002w5-Gc for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:36 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:43297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHIdL-0002vr-BE for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:35 -0400 Received: by mail-pf0-x241.google.com with SMTP id j20-v6so3426914pff.10 for ; Fri, 11 May 2018 17:43:35 -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=CZ8t3rsGP1Vnm6i0MzTN7S1/lYSmU4XX4UAXyYCKUoA=; b=kAv9PJ7Zw5WZHg57XFZgcQfiJ0wip0nYIcnf7VKsrG8GdR1QD6I35sDs7w+Ug9UYtR sncjMP4gSyZyonOSiKgEHbgE48ciFzQYhyMxsD+5LKZTzKn4NStgZ4DZwXNMQP/uU/2N JQtjGGJE5oSHY8Cv+IhVu2Kf6N7VCgFvOINHI= 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=CZ8t3rsGP1Vnm6i0MzTN7S1/lYSmU4XX4UAXyYCKUoA=; b=dgUbL5+n5I8jbgOaEGYznzDU8mhCXppwDPbOy8SGw4+5wRytKXsWyDAbIC48/XYNjZ e8ltn6XM3QQWgZW+SKwLW5xfd/6/Czm+Rw4ZjlBFJJRyAfweY65m+dDElsMh/CdDZZ0L ytRUcpCdQuH7qIIcY9EsvyL6KvPPkQB46jK7IT08f2GAeXkDsTu42BHT6Wu8SsoB/s8h hzOyz4lXzvLWWgEDa8EBxRoXdkg0T0F1ZPRhZoIg0WIxNPUyXmcNkVPFYmmHWiIUhndW nNV4OQpZZlXYFOxzkxoM2kwzp+Jze+SFm2gnUUHyCo1mg0szr3ExE6OgxkPJeQG6g5c8 oucw== X-Gm-Message-State: ALKqPwfcPIhsfnz3dyDWG1jFPRLNJr2QSciBVKKySJT35C5GTqCuCjbJ 52TcdMFf5SUodC2jB8ujvHMA+Kd0S5k= X-Received: by 2002:a65:5b4d:: with SMTP id y13-v6mr1005824pgr.152.1526085814061; Fri, 11 May 2018 17:43:34 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id k84-v6sm10756406pfh.93.2018.05.11.17.43.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 17:43:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 11 May 2018 17:42:58 -0700 Message-Id: <20180512004311.9299-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180512004311.9299-1-richard.henderson@linaro.org> References: <20180512004311.9299-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 14/27] target/arm: squash FZ16 behaviour for conversions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée The ARM ARM specifies FZ16 is suppressed for conversions. Rather than pushing this logic into the softfloat code we can simply save the FZ state and temporarily disable it for the softfloat call. Signed-off-by: Alex Bennée Signed-off-by: Richard Henderson --- v4 - float16_to_floatX squished the wrong softfloat bit for FZ16; need to adjust input denormals in this case. --- target/arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) -- 2.17.0 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index a1c1dc5bbe..e05c7230d4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11542,22 +11542,54 @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) /* Half precision conversions. */ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) { - return float16_to_float32(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float32 r = float16_to_float32(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; } float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) { - return float32_to_float16(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r = float32_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; } float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) { - return float16_to_float64(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float64 r = float16_to_float64(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; } float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) { - return float64_to_float16(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r = float64_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; } #define float32_two make_float32(0x40000000)