From nobody Sun May 19 00:42:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167386077012718.04859411146481; Mon, 16 Jan 2023 01:19:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHLeF-0000oC-Gi; Mon, 16 Jan 2023 04:19:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeE-0000nD-2G for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:22 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeA-0003CK-LF for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:21 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MJW5G-1p21ik1YFc-00JqsI; Mon, 16 Jan 2023 10:19:14 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mark Cave-Ayland , Richard Henderson Subject: [PULL 1/4] target/m68k: pass quotient directly into make_quotient() Date: Mon, 16 Jan 2023 10:19:09 +0100 Message-Id: <20230116091912.1882152-2-laurent@vivier.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230116091912.1882152-1-laurent@vivier.eu> References: <20230116091912.1882152-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:4uwzH+WVJlRiDQcuhBFJjYvAnMhAgc/8+H/Ad1qnOb5T/a/2SEK 4K6hWOSVAZmZb1cWElztYSolDHPHVpNjOcLCimnY9KpRCPa4uGWNWCtPHJOslTE68Ir/Bgx 784LtK5r71cJ3JwAGLiwjIi/FLuT1zIyMfnDGhhsHuu5T1akG2Og/K+XKF/9Hi+aiK4RKrh OmVWJ8Sq5mgrT26s27BYw== UI-OutboundReport: notjunk:1;M01:P0:w30Jta8nVkA=;xwx1L0eimVEXfljSdgG03tqz2q9 yDtoNNTSUsj/nz6AlF8bxhxh2aGfjXqf+1mcbhXGYkEcqm4ljPPQCcreAQwlcExqbDoDlqP+E b3oeKWaTP57IYdx1HhMdxVxcGQQw9+Z/bfxfAlpqZ0EF9s0Y6GqGbUbqvxDnVshdu1U27duOO jnQ0sN51t1M7hQO4ubSbchEdo0arfuxelZTNmuKtLpQQpqw9LNpqoAbS9olhS5piaOHedo9df d1G4Fo6S8lhx4AKDACjperqKFjv5DD+Sb9PI7Pk7GWjbMW+BSKw75CoIICZnVQB1eUtSLJ/jw 7QvzuWJbi/kgfXK2WPgWkfdwccayIFlWh5ObpxwyBW+pqlgZANekVYfuxRw8dWMukvvYTolgJ EfzHZ5IlvHEqZ2CTU3XPKHy2hNtkwjPibPpcYRSDaxIsztUniE74bJEXLcyztPVwLTE8/ODbX edEoIxVYy2hAAI+Lb6rkjD/OgP5qLLdwtFalL0RAlNmS9Cmg5jIW6nop4dDObB567Cx2/n1ql uH6PUxrdfTyKcPd1/tKqPAhvTFQ15oDsB+jQU3I1Dc2iX6eMy3j3FwWj6zILzA44Lb0lPkEUY 6v7UTBlgsAnNvijY1kEToDQUqj34i5SQ9YX8bGbBiUt1FTC4lB/jHyyFmMEImjgwG2ZSekB6C lk0QDR8qOX0Rh/hm8nnTDgFIALwIr225XbTCBrhNpQ== 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=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: 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-ZM-MESSAGEID: 1673860771841100007 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20230114232959.118224-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/fpu_helper.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index fdc4937e29e1..0932c464fdae 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -515,16 +515,10 @@ uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env= , uint32_t addr, return fmovem_postinc(env, addr, mask, cpu_ld_float64_ra); } =20 -static void make_quotient(CPUM68KState *env, floatx80 val) +static void make_quotient(CPUM68KState *env, int32_t quotient) { - int32_t quotient; int sign; =20 - if (floatx80_is_any_nan(val)) { - return; - } - - quotient =3D floatx80_to_int32(val, &env->fp_status); sign =3D quotient < 0; if (sign) { quotient =3D -quotient; @@ -538,14 +532,22 @@ void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPRe= g *val0, FPReg *val1) { res->d =3D floatx80_mod(val1->d, val0->d, &env->fp_status); =20 - make_quotient(env, res->d); + if (floatx80_is_any_nan(res->d)) { + return; + } + + make_quotient(env, floatx80_to_int32(res->d, &env->fp_status)); } =20 void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { res->d =3D floatx80_rem(val1->d, val0->d, &env->fp_status); =20 - make_quotient(env, res->d); + if (floatx80_is_any_nan(res->d)) { + return; + } + + make_quotient(env, floatx80_to_int32(res->d, &env->fp_status)); } =20 void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val) --=20 2.38.1 From nobody Sun May 19 00:42:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673860791623737.4818163725762; Mon, 16 Jan 2023 01:19:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHLeF-0000nr-Hc; Mon, 16 Jan 2023 04:19:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeD-0000nA-UH for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:21 -0500 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeA-0003CM-Kc for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:21 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MVMJ7-1p7p1J3Zax-00SLzt; Mon, 16 Jan 2023 10:19:15 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mark Cave-Ayland , Richard Henderson Subject: [PULL 2/4] target/m68k: pass sign directly into make_quotient() Date: Mon, 16 Jan 2023 10:19:10 +0100 Message-Id: <20230116091912.1882152-3-laurent@vivier.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230116091912.1882152-1-laurent@vivier.eu> References: <20230116091912.1882152-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:OZadBC+rcuKn/kNj+/VVUkXnBS/k4iqiQluihP4L2B5VEx00fKi H98WeMmtDkwc/wyNMKMk8rHOdvOTCQUiDDEez7zTpuVdUq5x3ywU59Wu2Vg1QuFQHS0MNLP GuiJiG7l1YLtLiuaMUCVG2stq8wLIftTaDyu3bvx3c4uDUSThbn7prSC8gQv2jVFKth2iA/ CPnIECwOaS7Pbuc/BYynQ== UI-OutboundReport: notjunk:1;M01:P0:dAQZHaaW/Is=;JKoWJUDmGpqVXN9ZbcGXgHzd7Ti PcY+5oKjJx9lMRAC00bTPupsyPqDnbH46JJDln/X9IYV28LsnU7DOfIuEBNoCOiy1gmWHF55u 6vFza8Dpi/BsDCjdy9XTPJ/+rwQ0jYwzwYSt1n1L4+vu7bkjlPy103xLXnv8m8JE5aDb6dE7b bmBAUduy6oOzmtIos8vL3ECjmzo+A76SlA14Y5hT45F0T9vktGkENgwSU+G0/VDqxwWJd3tr2 E0eO2lNO4GyMyqhaxaEY6kC1zyfrTHEltIPcy/q4HjW6K/OvDrhixhRxMuRc2SCbVUibyKANs T8chpn4YPcfNmjsmv0FVCdZbAu7OaJxnusLzHjOtnRsdyh1ymV0hXG4azOKPFMRNIwCIBbjDN FB2QtNf7uWB80FZG2bFE7HrJXXgFOdQUmX6mSihoT/tS6J8h1qlZnsuQ4fELi40HUfks/LHJx k7842aSwblBy4QIkdrLa0Kl2IXRkID9kLVIYub8WFVdmuj9knDWA49Y47FkkLHFqrpPqvAi/G wQKH2AswkDLJsrfl5y6VBe1dT8Yly0isSyn14b66fLbJjT3laKX0PUwW8WkMdAi4DpQLUpcfV P912Jlvax+rSAHtgOT6PYcgIvumJE1m5UbqsjY+XbHPRXaYTGRqXW33uQQEfvSUU79Lg5lq3W 4DV/WW8uAIhAOWVitWFIv1kxbyd6LQRBMXvKsNWktg== 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=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: 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-ZM-MESSAGEID: 1673860791778100005 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland This enables the quotient parameter to be changed from int32_t to uint32_t = and also allows the extra sign logic in make_quotient() to be removed. Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20230114232959.118224-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/fpu_helper.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 0932c464fdae..76b34b898879 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -515,39 +515,42 @@ uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env= , uint32_t addr, return fmovem_postinc(env, addr, mask, cpu_ld_float64_ra); } =20 -static void make_quotient(CPUM68KState *env, int32_t quotient) +static void make_quotient(CPUM68KState *env, int sign, uint32_t quotient) { - int sign; - - sign =3D quotient < 0; - if (sign) { - quotient =3D -quotient; - } - quotient =3D (sign << 7) | (quotient & 0x7f); env->fpsr =3D (env->fpsr & ~FPSR_QT_MASK) | (quotient << FPSR_QT_SHIFT= ); } =20 void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { + uint32_t quotient; + int sign; + res->d =3D floatx80_mod(val1->d, val0->d, &env->fp_status); =20 if (floatx80_is_any_nan(res->d)) { return; } =20 - make_quotient(env, floatx80_to_int32(res->d, &env->fp_status)); + sign =3D extractFloatx80Sign(res->d); + quotient =3D floatx80_to_int32(floatx80_abs(res->d), &env->fp_status); + make_quotient(env, sign, quotient); } =20 void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { + uint32_t quotient; + int sign; + res->d =3D floatx80_rem(val1->d, val0->d, &env->fp_status); =20 if (floatx80_is_any_nan(res->d)) { return; } =20 - make_quotient(env, floatx80_to_int32(res->d, &env->fp_status)); + sign =3D extractFloatx80Sign(res->d); + quotient =3D floatx80_to_int32(floatx80_abs(res->d), &env->fp_status); + make_quotient(env, sign, quotient); } =20 void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val) --=20 2.38.1 From nobody Sun May 19 00:42:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16738608209491003.6621479519225; Mon, 16 Jan 2023 01:20:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHLeG-0000pP-CZ; Mon, 16 Jan 2023 04:19:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeE-0000nC-2J for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:22 -0500 Received: from mout.kundenserver.de ([212.227.17.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeA-0003CP-PA for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:21 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MK3mS-1p1TDx1XWI-00LVIe; Mon, 16 Jan 2023 10:19:15 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mark Cave-Ayland , Richard Henderson Subject: [PULL 3/4] target/m68k: fix FPSR quotient byte for fmod instruction Date: Mon, 16 Jan 2023 10:19:11 +0100 Message-Id: <20230116091912.1882152-4-laurent@vivier.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230116091912.1882152-1-laurent@vivier.eu> References: <20230116091912.1882152-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:6xYoaJXji7stxpwQHpL7U2GRZiwZnRh73P6CWgz21qjDfyMheeX RG+JhlwK/GJpWy/ZZsgoP8L98teTl3cIGb1pQgVEGQHEsKElkgnzaDzkPYMaQZHRakgagtV UbfPfizicgNOkRUo+2RGELYpY6oCTuQxi6qAC7k4sd6BOZ1tZ/h0ZkmukymxfIFoLqp5pls 1Eua47rlRmFiDeZLm/2hQ== UI-OutboundReport: notjunk:1;M01:P0:1k+z/l6IYM0=;dxmTnpAda8324cAEffjnJHGcpn/ LZtuR6TX3ULQDpMeS9pzBcWpxNnKG1iyoSRC096/ottju2ixeuPVnbB+ctBheCRumhsr5tulh FoiQDSG+QBaJ0S8ULn/HlHDSDMoAxdSOPlN+5IiVOhccHuTqZHuPJBFuEq1kW9IXPlLKYU8Ir n3BJZDWj00WmCGTazAirkM27Y1W1nImw86YSEpcvGea6AaJo8kx3PXqnrzg9IF0S0MzWlV+6o R28ERzxDG5Pnbv+QjCFUuLMibcps0UxcqbkTZbXY2Tki+O35AazTO0oDXsbq9rExmqauMbewl ZozyB2+HH1+BZnv/MJ5bPQoX1V1+Qkdbi0ZKnrWIN4iMNOlteDeZSY2zJJtVVkqHs8tsedyU3 bhp1t8tRiA0S7DHuBUC+Cfo02IkqXe+mX/0ZjWyywtVELNuoTJu/4daf8WdT0iw9VWw1GNM33 yveGU7sPJijwpVcA6JKjJCsrOxXCSVALBfhLgfp8ZMcy/5Eb1S4oZkIfrvWXHz9wFfK8nO9ok i2ystGwxI5e9uBZPRbJ+XVsX6Mw48Dgma5C0Smr+NBE5bdq55CrdiY5VqMKz+Mif0vC4tQZ4N AdRvAmhfE9dTlWmowrPBPy9s6UI+RGW4qI2r4KT2N/lCwtT55kVquE8ABca6//OTis6vaiNm+ +tEa6LY/wD/JVhdAzVegf+fvRMmBEMz++xRazDkVbw== 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=lists.gnu.org; Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: 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-ZM-MESSAGEID: 1673860821940100001 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland The FPSR quotient byte should be set to the value of the quotient and not t= he result. Switch from using floatx80_mod() to floatx80_modrem() which returns the quotient as a uint64_t which can be used for the quotient byte. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20230114232959.118224-4-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/fpu_helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 76b34b898879..5fd094a33cff 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -523,17 +523,16 @@ static void make_quotient(CPUM68KState *env, int sign= , uint32_t quotient) =20 void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { - uint32_t quotient; - int sign; + uint64_t quotient; + int sign =3D extractFloatx80Sign(val1->d) ^ extractFloatx80Sign(val0->= d); =20 - res->d =3D floatx80_mod(val1->d, val0->d, &env->fp_status); + res->d =3D floatx80_modrem(val1->d, val0->d, true, "ient, + &env->fp_status); =20 if (floatx80_is_any_nan(res->d)) { return; } =20 - sign =3D extractFloatx80Sign(res->d); - quotient =3D floatx80_to_int32(floatx80_abs(res->d), &env->fp_status); make_quotient(env, sign, quotient); } =20 --=20 2.38.1 From nobody Sun May 19 00:42:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673860788612100.95876719444709; Mon, 16 Jan 2023 01:19:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHLeG-0000pQ-GH; Mon, 16 Jan 2023 04:19:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeE-0000nG-5D for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:22 -0500 Received: from mout.kundenserver.de ([212.227.17.24]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHLeB-0003CU-2L for qemu-devel@nongnu.org; Mon, 16 Jan 2023 04:19:21 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MLyvH-1ozXoQ3aiX-00Hw87; Mon, 16 Jan 2023 10:19:16 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Laurent Vivier , Mark Cave-Ayland , Richard Henderson Subject: [PULL 4/4] target/m68k: fix FPSR quotient byte for frem instruction Date: Mon, 16 Jan 2023 10:19:12 +0100 Message-Id: <20230116091912.1882152-5-laurent@vivier.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230116091912.1882152-1-laurent@vivier.eu> References: <20230116091912.1882152-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:jV9j+LW0sPg5/X1vogxojXtutHc00qoQwgctwjpMfMIcl2CoXLZ pqhgegn8ydc2p2OphKN1f05w8HJl3X/3CSIxKtfgFeavgzq5+U0pvin2yG8WFZaIzuePCNJ gQ8/SztqLtDgl+sraxUrznFs3DuNt00KL8ogxnlGnhQH51++6Uz+Wn3Jtz1+cweqRtJWkw3 OCU77ybN4uLKd16Z0utSA== UI-OutboundReport: notjunk:1;M01:P0:tGqbjgI6OV8=;vcU2pTwem0YPMHa05ua65qag1MT yYY8Yy5QxwWWrQlUc2cCdpNfXp/RngkOwYqJPh/Z7Xnh4BVptu0U0TElmXsxz8y9d3SZvtjOy qFqFh3Rb7G8ePuXdwWR1TGsztLVB49dAjrOw1pcE+aej7kDEwhC3DRO1kBU3aR3kpHLObER2c 5JA/mEUHJq+eVkrtrS45TSZikSX7geL6R7WmemWSORhdqoyBTLQZQfvMDMpABMXWQu09QQ6DL MMjk4EZXeN+4GToBX6blYzJRlxSA0kU2sSFTYv41l6PS0zwGOMjrCnJeuQvQrx1+IFfRdzR/Z zn7AOj4Lk/6tNqxEbfha508d7mU1/2/FkNRLgWDuoElBcfBWO2JKWieZRcGeLyPKJdlFinYwv JR3ezar83UA8vadSk5DDa7AKjOhm1MwW7gHEx9Gi2dQEqxMCb9OfIffzXslvs6MVx2oud4vXC IpxidkrPoHePKur2Y/AdIEODs2fVD5SxhNtmM96uF0J/xit+/P1MYo5E1rQ8K2qrmYp1WXpO/ guyTnGu81WEaB2l6P1Z29wSJ4vQvzjnaiykA/Ow0V99HzPOoAjrUkSMe+jXCZnqYD39qkeYHM Y85dlojxfIDPcXP4L7Lm/d83UOs7qqr1DBWEF/ky3iMrMMhyCkkXz65vN5iHapGoT6kJOgIOe 03CtAmaRZce2IEnBoPSWwZlu4+Ou7ISVq4y9TntCMQ== 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=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: 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-ZM-MESSAGEID: 1673860789851100001 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland The FPSR quotient byte should be set to the value of the quotient and not t= he result. Manually calculate the quotient in the frem helper in round to near= est even mode (note this is different from the quotient calculated internally f= or fmod), and use it to set the quotient byte accordingly. Signed-off-by: Mark Cave-Ayland Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1314 Reviewed-by: Richard Henderson Message-Id: <20230114232959.118224-5-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/fpu_helper.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 5fd094a33cff..3a37d8f584d6 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -538,18 +538,27 @@ void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPRe= g *val0, FPReg *val1) =20 void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { - uint32_t quotient; - int sign; - - res->d =3D floatx80_rem(val1->d, val0->d, &env->fp_status); - - if (floatx80_is_any_nan(res->d)) { - return; + FPReg fp_quot; + floatx80 fp_rem; + + fp_rem =3D floatx80_rem(val1->d, val0->d, &env->fp_status); + if (!floatx80_is_any_nan(fp_rem)) { + float_status fp_status =3D { }; + uint32_t quotient; + int sign; + + /* Calculate quotient directly using round to nearest mode */ + set_float_rounding_mode(float_round_nearest_even, &fp_status); + set_floatx80_rounding_precision( + get_floatx80_rounding_precision(&env->fp_status), &fp_status); + fp_quot.d =3D floatx80_div(val1->d, val0->d, &fp_status); + + sign =3D extractFloatx80Sign(fp_quot.d); + quotient =3D floatx80_to_int32(floatx80_abs(fp_quot.d), &env->fp_s= tatus); + make_quotient(env, sign, quotient); } =20 - sign =3D extractFloatx80Sign(res->d); - quotient =3D floatx80_to_int32(floatx80_abs(res->d), &env->fp_status); - make_quotient(env, sign, quotient); + res->d =3D fp_rem; } =20 void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val) --=20 2.38.1