From patchwork Tue May 15 22:25:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135939 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp76585lji; Tue, 15 May 2018 15:29:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZooVHzGyUs1VjovSlnL/j2HL0cVENfctRcYW3s9UteWF2PshsNqkWQe0bxSQp0yq/nGXWBG X-Received: by 2002:aed:2962:: with SMTP id s89-v6mr15384729qtd.162.1526423383706; Tue, 15 May 2018 15:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526423383; cv=none; d=google.com; s=arc-20160816; b=TRaMGSIRn4s9+6G4hq5kfTdYEksLZZhCFQjOk8H1k/srLekYu7m/VsZ2s7x4STXBpj ApvOP0wHoggOUVirDaumJWIZGidLJ7Ch4XBjyal8cD7j/4uwc0tR8QLYxBwV0xf4iKED l1IVw4VBVnmKAPDU26lla3yx/fgeQ4nr41hdvq+diJw8EyzeQ+ri+cmxsa9kj0o8us0s CRERB1Tu4YP5ghMhn/nNStFSO5YhUA/Y90ST6JmUWtzikc7DwNPck0/yh67Cubf7lZFh kObM17yc4lvaq4tfYL/3Sr03bFCDfsZvHihyh1qZXtSR6PM7ZLoWkGd3e7R9qY67cpo5 hIpg== 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=kkdclCQGVBM2KvXTD5izLcmQOYfhQuj8dN6mUZN/37s=; b=LJjCr0lsUMHXvgCRMnT53PDM4p3ZjFj88hE/TDx5tNLeq8z58/0S5skj9GpEvINLkz RQJqulf+pstikzyQVUJKGs2tp7Dm6zao35tW65tYL8SyVgDJP9z2QpMsjN9VDNjU81dW Uij05yRMpaN3RbAQyWYQtj2sWQW1y46amxvSUOGQjr9mWbPF9QLviobjT1wUCiKwGSDM CTTuYhkhIBR4gjavLOz48q0GaMOozjvoZavv0mDdQIBmyVziVHhvGqejJAkNwTq+PTtE ZmC2VMH0OOeb9AldOEAl37S9oiyg7UjU/bbBERZN0XHWQqQjzO7ivCSujmqOCO0f1zbs XsJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=koANexUL; 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 p128-v6si1123734qka.266.2018.05.15.15.29.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 May 2018 15:29:43 -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=koANexUL; 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]:36322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiRz-0005v0-3n for patch@linaro.org; Tue, 15 May 2018 18:29:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiOP-0003Oj-AS for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIiON-000556-MW for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:01 -0400 Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:46878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIiON-0004wT-Gt for qemu-devel@nongnu.org; Tue, 15 May 2018 18:25:59 -0400 Received: by mail-pg0-x22e.google.com with SMTP id u8-v6so530607pgp.13 for ; Tue, 15 May 2018 15:25:59 -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=kkdclCQGVBM2KvXTD5izLcmQOYfhQuj8dN6mUZN/37s=; b=koANexULSM5BJWU3oFRtzvo45qGWWnz7iQXmM9aI3Uu32u7/cRqhzMPuclxIkNfoUR 0pedsqtgT0gFtY/mJdTQ1Tzw21z0TjqvXvuzG6cSPXxS5K53Q/7aAUEXqr58VN4Y+iUP Dyai2oUCPS+GCCE6r+K7P6QSeqNY6IhDyTt7I= 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=kkdclCQGVBM2KvXTD5izLcmQOYfhQuj8dN6mUZN/37s=; b=agWg8mMX1/74+B5/FZsOzTCz/VqkYEfq5DRLuDDjMUWNJFHZjMACnv41sUHDm0yn0n h8rhE+IG3uwcO0K4weza7JTEqWsMrUjFWuExfAk7uTgYCwVL470LmR2WH8PQGF8Z+k81 tt2Z8/cYxzwQszgVEc71l0n6Bpsa3Ba4qbSU9/ATG14e/wsEcJ0LQd5+pQ7a/5Pky6rm j1LFyInnGaX6aRxaZKGYPogI566B5Q5ZJHjHm+WybqWUSuL9OGoD9V75+YaNrd0nW7kq gVlWRA8p8A02088GkgfsgLqc/7VtyGNFyGUT9PLyJEFwqGPMAR8FgXZ0Lz66VTzG1AKq 6hvw== X-Gm-Message-State: ALKqPwf5+Ybb/9hoWuYzFu3ZDbZLYr/BNbiXwIfhuR92EWEft2x9YIeM wWv3cufTmfOxD8g3h6J5pyBcfSN2fH4= X-Received: by 2002:a65:4b8d:: with SMTP id t13-v6mr12344543pgq.53.1526423158137; Tue, 15 May 2018 15:25:58 -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 g11-v6sm941419pgq.62.2018.05.15.15.25.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 15:25:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 15:25:22 -0700 Message-Id: <20180515222540.9988-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180515222540.9988-1-richard.henderson@linaro.org> References: <20180515222540.9988-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:c05::22e Subject: [Qemu-devel] [PATCH v6 10/28] 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. Reviewed-by: Peter Maydell 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 diff --git a/target/arm/helper.c b/target/arm/helper.c index 1762042fc7..238a3ceba8 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)