From patchwork Wed Mar 23 11:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 553743 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp3315199mag; Wed, 23 Mar 2022 04:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo/XmRGMTdqe5ydy0e6ogHoor9MQ343PoHweeHzjFLLzkg04JApY/GtrAjvWc5ihehb7Cg X-Received: by 2002:a05:6214:c2a:b0:440:f702:2195 with SMTP id a10-20020a0562140c2a00b00440f7022195mr20332797qvd.37.1648036112229; Wed, 23 Mar 2022 04:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648036112; cv=none; d=google.com; s=arc-20160816; b=eAAUG9pBOkaG5+KrEClaOHPA+cUDKnmiYxgumSScKp9NwxWm+5sOiQU5JriwB8sfpC 1ECsS07l6HCEfyeskw13kCRDkVjOLllJLvT0Wprbn/l9rtHDGpNLUJcb3MiQRN9cF949 /F3zXNu70AZqRNz7SnioGHR0OAjPi9JrupuWaSftQlrjON1R2nucF2GtBtJmTmQc0moX eGvNmJ3Yg4JacLmCAEQI+tUO3ASKQ3MAH/M6VSjnlIUyyWQDRIH6IGFS9WgTh1UnRVbS UZmikXQGa9c/iWCFX13ZHZYtvxiAqX39RaU4aP+SdIphhak3ZzH4V7T/6JPqGRdXZEzO /xSQ== 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=U68ak4unAbqGYAM4zXFr3lp59AqwKDw7viO7+1coraY=; b=zJh1rEk6/3MJTH8kW3Vq/msH3ZO07OiKofdRWSqlxjQbfBClR1xsXubNMtHwG8sncS CtFqWcFOt3o0VAySKwjc4/fxhnMmxAG/+oQAzGxBDTfxgE4vyyBWr1toKZILnhx8jjMs YC9Mh4iGOoJhu/iVVYZw+QZxSUJK8LdpUxAmY99m8ydQ8qQHi1axWOyoBC3l8Fb8jBUS b/P689Ia3VxHAIXJl/2JRryZHFnf5KC/v6wIt3UywVSrYmfGVXHLILazp4gp+a+CJM7R zZbZQr9lHG9czLACTcLgqfdFNz6EwWrQ2LmSRQcVNvqpaK1gq+flI91jm0w/8R3BZm4M EikQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Pb/lq17w"; 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=fail (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 i8-20020a0cf388000000b00440e46a7cbfsi3535944qvk.349.2022.03.23.04.48.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Mar 2022 04:48:32 -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=fail header.i=@linaro.org header.s=google header.b="Pb/lq17w"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWzTa-0008OW-Hr for patch@linaro.org; Wed, 23 Mar 2022 07:48:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWz96-0001uH-NB for qemu-devel@nongnu.org; Wed, 23 Mar 2022 07:27:20 -0400 Received: from [2a00:1450:4864:20::32a] (port=54823 helo=mail-wm1-x32a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nWz94-00064D-0c for qemu-devel@nongnu.org; Wed, 23 Mar 2022 07:27:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id r64so727017wmr.4 for ; Wed, 23 Mar 2022 04:27:17 -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=U68ak4unAbqGYAM4zXFr3lp59AqwKDw7viO7+1coraY=; b=Pb/lq17wWi46rH6FqxPBY7PhRwt8LILO26RFzGYeOLj6klM+esydPvafT/VzH/f9fQ MLnzxp0wtkKbqwDyyoB7MyLoJlgaOuYnhWpN5stTch2U1ruEYqBD1iuka8zBOEu6BnJi hjIzJ6sctHkk7LXDrE2iovyNBw2E8sf2B+pYNRnTEGE5qiOCmDt+MJqKA3TeHN1+VTtW K19gZjR1km++p29vTNKPPfiyPyI9rBNMY4Mj0qc5Tmz9PoaAWxFwZDiAYgAq2nJJE8xG C6iZ1AE+inn9cwS/18sKV1XkSv6PMplp9p4s2GGWyy93DeDItmS8oyQd6rtfnR/mMixo ihPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U68ak4unAbqGYAM4zXFr3lp59AqwKDw7viO7+1coraY=; b=2Pq8u23tXxSj2966lbtkMA3LSD/6b2El7DXSHA29aEsfwrfzgsubR4Nvv2+eWIn4O8 u7jduo/9EU4GJtAxub5WlV5NaujXuDuyG0f+kUlFks+3uP3fF6dsE/Xzntqqn1ZUsApS ySj3ET4sJbgZMV+A0vDrefYYhxbYP3Cr8AoKqGMsnpCdQRMH9x5cqOb4mqEPn8dCbC1T amltQA91TP+7Mg17cKveXXlRCFaLLKl1nW6T0iBnmKFLAQ9FL2/6dVsZY/dQYLvFoy0/ GbzTZ6kFkSuLb7D8Tuf+shE9NjhXGrjSzlt+9NWJEYlThsGxI49DvzRK66g1y5s/l2n6 AR7Q== X-Gm-Message-State: AOAM5310CFInBy9fKP98qeygysSis0qNZV9fMRJlXU/XENFICIUbm9Q2 U6S6CEikYEPJXM8gVQclcut89A== X-Received: by 2002:a05:600c:4f0f:b0:38c:c8f5:73e7 with SMTP id l15-20020a05600c4f0f00b0038cc8f573e7mr1950730wmq.201.1648034836737; Wed, 23 Mar 2022 04:27:16 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c4e8d00b0038c949ef0d5sm4089640wmq.8.2022.03.23.04.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 04:27:12 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A33EA1FFBA; Wed, 23 Mar 2022 11:27:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 2/8] target/i386: force maximum rounding precision for fildl[l] Date: Wed, 23 Mar 2022 11:27:05 +0000 Message-Id: <20220323112711.440376-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220323112711.440376-1-alex.bennee@linaro.org> References: <20220323112711.440376-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Eduardo Habkost , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , qemu-devel@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The instruction description says "It is loaded without rounding errors." which implies we should have the widest rounding mode possible. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/888 Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20220315121251.2280317-4-alex.bennee@linaro.org> diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index cdd8e9f947..ebf5e73df9 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -237,24 +237,37 @@ void helper_fldl_ST0(CPUX86State *env, uint64_t val) merge_exception_flags(env, old_flags); } +static FloatX80RoundPrec tmp_maximise_precision(float_status *st) +{ + FloatX80RoundPrec old = get_floatx80_rounding_precision(st); + set_floatx80_rounding_precision(floatx80_precision_x, st); + return old; +} + void helper_fildl_ST0(CPUX86State *env, int32_t val) { int new_fpstt; + FloatX80RoundPrec old = tmp_maximise_precision(&env->fp_status); new_fpstt = (env->fpstt - 1) & 7; env->fpregs[new_fpstt].d = int32_to_floatx80(val, &env->fp_status); env->fpstt = new_fpstt; env->fptags[new_fpstt] = 0; /* validate stack entry */ + + set_floatx80_rounding_precision(old, &env->fp_status); } void helper_fildll_ST0(CPUX86State *env, int64_t val) { int new_fpstt; + FloatX80RoundPrec old = tmp_maximise_precision(&env->fp_status); new_fpstt = (env->fpstt - 1) & 7; env->fpregs[new_fpstt].d = int64_to_floatx80(val, &env->fp_status); env->fpstt = new_fpstt; env->fptags[new_fpstt] = 0; /* validate stack entry */ + + set_floatx80_rounding_precision(old, &env->fp_status); } uint32_t helper_fsts_ST0(CPUX86State *env)