public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact @ 2023-11-17 0:29 xry111 at gcc dot gnu.org 2023-11-17 11:18 ` [Bug target/112578] " xry111 at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: xry111 at gcc dot gnu.org @ 2023-11-17 0:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 Bug ID: 112578 Summary: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: xry111 at gcc dot gnu.org Target Milestone: --- $ cat t.c #include <assert.h> #include <fenv.h> float f[4] = { 11.4, 5.14, 19.19, 8.10 }; int main() { for (int i = 0; i < 4; i++) f[i] = __builtin_floorf (f[i]); assert (!fetestexcept (FE_INEXACT)); } $ cc t.c -O2 -lm -fno-fp-int-builtin-inexact -mlsx $ ./a.out a.out: t.c:11: main: Assertion `!fetestexcept (FE_INEXACT)' failed. Aborted (core dumped) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org @ 2023-11-17 11:18 ` xry111 at gcc dot gnu.org 2023-11-17 11:31 ` chenglulu at loongson dot cn ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: xry111 at gcc dot gnu.org @ 2023-11-17 11:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-11-17 See Also| |https://github.com/loongson | |-community/discussions/issu | |es/7 Keywords| |wrong-code Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |xry111 at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- I've made a patch and it's under testing. I've seen some "random" gcc.dg/torture/builtin-fp-int-inexact.c failures recently but maybe it's not related, we don't enable LSX/LASX compiling it anyway... But who knows. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org 2023-11-17 11:18 ` [Bug target/112578] " xry111 at gcc dot gnu.org @ 2023-11-17 11:31 ` chenglulu at loongson dot cn 2023-11-17 20:54 ` xry111 at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: chenglulu at loongson dot cn @ 2023-11-17 11:31 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 --- Comment #2 from chenglulu <chenglulu at loongson dot cn> --- (In reply to Xi Ruoyao from comment #1) > I've made a patch and it's under testing. > > I've seen some "random" gcc.dg/torture/builtin-fp-int-inexact.c failures > recently but maybe it's not related, we don't enable LSX/LASX compiling it > anyway... But who knows. This problem of random errors has always existed.This is a known problem. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org 2023-11-17 11:18 ` [Bug target/112578] " xry111 at gcc dot gnu.org 2023-11-17 11:31 ` chenglulu at loongson dot cn @ 2023-11-17 20:54 ` xry111 at gcc dot gnu.org 2023-11-20 0:51 ` xry111 at gcc dot gnu.org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: xry111 at gcc dot gnu.org @ 2023-11-17 20:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- URL| |https://gcc.gnu.org/piperma | |il/gcc-patches/2023-Novembe | |r/637097.html See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=107723 Keywords| |patch --- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- https://gcc.gnu.org/pipermail/gcc-patches/2023-November/637097.html This fixes most of -ml[a]sx -fno-fp-int-builtin-inexact issues on LoongArch, except PR107723. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org ` (2 preceding siblings ...) 2023-11-17 20:54 ` xry111 at gcc dot gnu.org @ 2023-11-20 0:51 ` xry111 at gcc dot gnu.org 2023-11-29 7:07 ` cvs-commit at gcc dot gnu.org 2023-11-29 7:09 ` xry111 at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: xry111 at gcc dot gnu.org @ 2023-11-20 0:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- URL|https://gcc.gnu.org/piperma |https://gcc.gnu.org/piperma |il/gcc-patches/2023-Novembe |il/gcc-patches/2023-Novembe |r/637097.html |r/637316.html See Also|https://github.com/loongson | |-community/discussions/issu | |es/7 | --- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to Xi Ruoyao from comment #3) > https://gcc.gnu.org/pipermail/gcc-patches/2023-November/637097.html > > This fixes most of -ml[a]sx -fno-fp-int-builtin-inexact issues on LoongArch, > except PR107723. Updated: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/637316.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org ` (3 preceding siblings ...) 2023-11-20 0:51 ` xry111 at gcc dot gnu.org @ 2023-11-29 7:07 ` cvs-commit at gcc dot gnu.org 2023-11-29 7:09 ` xry111 at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-11-29 7:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 --- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>: https://gcc.gnu.org/g:530348c418d9ec28aac5b151c15405bfb860e5c4 commit r14-5950-g530348c418d9ec28aac5b151c15405bfb860e5c4 Author: Xi Ruoyao <xry111@xry111.site> 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_<flsxfmt>, lsx_vftint_s_<ilsxfmt>_<flsxfmt>, 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, <FRINT_S:frint_pattern_s>v4sf2, <FRINT_D:frint_pattern_d>v2df2, round<mode>2, fix_trunc<mode>2): 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. (<simd_isa>_<x>vfrint<simd_frint_rounding>_<simdfmt>): New define_insn template for frint instructions. (<simd_isa>_<x>vftint<simd_frint_rounding>_<simdifmt_for_f>_<simdfmt>): Likewise, but for ftint instructions. (<simd_frint_pattern><mode>2): New define_expand with flag_fp_int_builtin_inexact checked. (l<simd_frint_pattern><mode><vimode>2): Likewise. (ftrunc<mode>2): New define_expand. It does not require flag_fp_int_builtin_inexact. (fix_trunc<mode><vimode>2): 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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/112578] LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org ` (4 preceding siblings ...) 2023-11-29 7:07 ` cvs-commit at gcc dot gnu.org @ 2023-11-29 7:09 ` xry111 at gcc dot gnu.org 5 siblings, 0 replies; 7+ messages in thread From: xry111 at gcc dot gnu.org @ 2023-11-29 7:09 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112578 Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #6 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- Fixed for trunk. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-11-29 7:09 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-17 0:29 [Bug target/112578] New: LoongArch: Wrong code -with -mlsx -fno-fp-int-builtin-inexact xry111 at gcc dot gnu.org 2023-11-17 11:18 ` [Bug target/112578] " xry111 at gcc dot gnu.org 2023-11-17 11:31 ` chenglulu at loongson dot cn 2023-11-17 20:54 ` xry111 at gcc dot gnu.org 2023-11-20 0:51 ` xry111 at gcc dot gnu.org 2023-11-29 7:07 ` cvs-commit at gcc dot gnu.org 2023-11-29 7:09 ` xry111 at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).