diff options
author | Xi Ruoyao <xry111@xry111.site> | 2022-11-06 23:16:49 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@xry111.site> | 2022-11-12 15:01:13 +0800 |
commit | 51a233b97cc9c51e63f03f2f5554e905f3f6c054 (patch) | |
tree | 3f3ecbb25183cace4e422ef04da1adfcbada9fd6 /gcc/range-op-float.cc | |
parent | e468dd40150ad20fe87d315c2638c572ca44dc3b (diff) | |
download | gcc-51a233b97cc9c51e63f03f2f5554e905f3f6c054.zip gcc-51a233b97cc9c51e63f03f2f5554e905f3f6c054.tar.gz gcc-51a233b97cc9c51e63f03f2f5554e905f3f6c054.tar.bz2 |
LoongArch: Add ftint{,rm,rp}.{w,l}.{s,d} instructions
This allows to optimize the following builtins if -fno-math-errno:
- __builtin_lrint{,f}
- __builtin_lfloor{,f}
- __builtin_lceil{,f}
Inspired by
https://gcc.gnu.org/pipermail/gcc-patches/2022-November/605287.html.
ANYFI is added so the compiler won't try ftint.l.s if -mfpu=32. If we
simply used GPR here an ICE would be triggered with __builtin_lrintf
and -mfpu=32.
ftint{rm,rp} instructions may raise inexact exception, so they can't be
used if -fno-trapping-math -fno-fp-int-builtin-inexact.
Note that the .w.{s,d} variants are not tested because we don't support
ILP32 for now.
gcc/ChangeLog:
* config/loongarch/loongarch.md (UNSPEC_FTINT): New unspec.
(UNSPEC_FTINTRM): Likewise.
(UNSPEC_FTINTRP): Likewise.
(LRINT): New define_int_iterator.
(lrint_pattern): New define_int_attr.
(lrint_submenmonic): Likewise.
(lrint_allow_inexact): Likewise.
(ANYFI): New define_mode_iterator.
(lrint<ANYF><ANYFI>): New instruction template.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/ftint.c: New test.
* gcc.target/loongarch/ftint-no-inexact.c: New test.
Diffstat (limited to 'gcc/range-op-float.cc')
0 files changed, 0 insertions, 0 deletions