From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B869385AC2F; Wed, 29 Nov 2023 07:07:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B869385AC2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701241672; bh=1887Gp5Z1NDWgOJ7N4Fc27VSSroZTMTNBtE6NzJ0g4k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jXYIwrZGCCMFsWPXG2wZTErt7Q5donCn2nwDc6TUeboPp5lSZjJ3t5TtzeAhnDYM1 T0G5p51XbMYPQOpuycHL43VT0Fyb+qQYiPvLLWwCn7cMyBWRb/1LAsAkK3wtYlfM2Y qRM0RByyrItpA0iq7eO8leL4+lG43Gg1yrJPBel4= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact Date: Wed, 29 Nov 2023 07:07:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: patch, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: xry111 at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112578 --- Comment #5 from GCC Commits --- The master branch has been updated by Xi Ruoyao : https://gcc.gnu.org/g:530348c418d9ec28aac5b151c15405bfb860e5c4 commit r14-5950-g530348c418d9ec28aac5b151c15405bfb860e5c4 Author: Xi Ruoyao Date: Sat Nov 18 04:48:20 2023 +0800 LoongArch: Fix usage of LSX and LASX frint/ftint instructions [PR112578] The usage LSX and LASX frint/ftint instructions had some problems: 1. These instructions raises FE_INEXACT, which is not allowed with -fno-fp-int-builtin-inexact for most C2x section F.10.6 functions (the only exceptions are rint, lrint, and llrint). 2. The "frint" instruction without explicit rounding mode is used for roundM2, this is incorrect because roundM2 is defined "rounding operand 1 to the *nearest* integer, rounding away from zero in the event of a tie". We actually don't have such an instruction. Our frintrne instruction is roundevenM2 (unfortunately, this is not documented). 3. These define_insn's are written in a way not so easy to hack. So I removed these instructions and created a "simd.md" file, then added them and the corresponding expanders there. The advantage of the simd.md file is we don't need to duplicate the RTL template twice (in lsx.md and lasx.md). gcc/ChangeLog: PR target/112578 * config/loongarch/lsx.md (UNSPEC_LSX_VFTINT_S, UNSPEC_LSX_VFTINTRNE, UNSPEC_LSX_VFTINTRP, UNSPEC_LSX_VFTINTRM, UNSPEC_LSX_VFRINTRNE_S, UNSPEC_LSX_VFRINTRNE_D, UNSPEC_LSX_VFRINTRZ_S, UNSPEC_LSX_VFRINTRZ_D, UNSPEC_LSX_VFRINTRP_S, UNSPEC_LSX_VFRINTRP_D, UNSPEC_LSX_VFRINTRM_S, UNSPEC_LSX_VFRINTRM_D): Remove. (ILSX, FLSX): Move into ... (VIMODE): Move into ... (FRINT_S, FRINT_D): Remove. (frint_pattern_s, frint_pattern_d, frint_suffix): Remove. (lsx_vfrint_, lsx_vftint_s__, lsx_vftintrne_w_s, lsx_vftintrne_l_d, lsx_vftintrp_w_s, lsx_vftintrp_l_d, lsx_vftintrm_w_s, lsx_vftintrm_l_d, lsx_vfrintrne_s, lsx_vfrintrne_d, lsx_vfrintrz_s, lsx_vfrintrz_d, lsx_vfrintrp_s, lsx_vfrintrp_d, lsx_vfrintrm_s, lsx_vfrintrm_d, v4sf2, v2df2, round2, fix_trunc2): Remove. * config/loongarch/lasx.md: Likewise. * config/loongarch/simd.md: New file. (ILSX, ILASX, FLSX, FLASX, VIMODE): ... here. (IVEC, FVEC): New mode iterators. (VIMODE): ... here. Extend it to work for all LSX/LASX vector modes. (x, wu, simd_isa, WVEC, vimode, simdfmt, simdifmt_for_f, elebits): New mode attributes. (UNSPEC_SIMD_FRINTRP, UNSPEC_SIMD_FRINTRZ, UNSPEC_SIMD_FRINT, UNSPEC_SIMD_FRINTRM, UNSPEC_SIMD_FRINTRNE): New unspecs. (SIMD_FRINT): New int iterator. (simd_frint_rounding, simd_frint_pattern): New int attributes. (_vfrint_): New define_insn template for frint instructions. =20=20=20=20=20=20=20=20=20=20=20 (_vftint__): Likewise, but for ftint instructions. (2): New define_expand with flag_fp_int_builtin_inexact checked. (l2): Likewise. (ftrunc2): New define_expand. It does not require flag_fp_int_builtin_inexact. (fix_trunc2): New define_insn_and_split. It does not require flag_fp_int_builtin_inexact. (include): Add lsx.md and lasx.md. * config/loongarch/loongarch.md (include): Include simd.md, instead of including lsx.md and lasx.md directly. * config/loongarch/loongarch-builtins.cc (CODE_FOR_lsx_vftint_w_s, CODE_FOR_lsx_vftint_l_d, CODE_FOR_lasx_xvftint_w_s, CODE_FOR_lasx_xvftint_l_d): Remove. gcc/testsuite/ChangeLog: PR target/112578 * gcc.target/loongarch/vect-frint.c: New test. * gcc.target/loongarch/vect-frint-no-inexact.c: New test. * gcc.target/loongarch/vect-ftint.c: New test. * gcc.target/loongarch/vect-ftint-no-inexact.c: New test.=