rtl: builtins: (not just) rs6000: Add builtins for fegetround, feclearexcept and...
authorRaoni Fassina Firmino <raoni@linux.ibm.com>
Thu, 13 Jan 2022 17:08:53 +0000 (14:08 -0300)
committerSegher Boessenkool <segher@kernel.crashing.org>
Mon, 24 Jan 2022 17:00:11 +0000 (17:00 +0000)
commit4343f5e256791a5abaaef29fe1f831a03bab129e
tree5847305e8cfd8ad62d664399b54252788735ee65
parentb1aa2a3cf1ba233ccd5a49fde85a2ca7e5f620e9
rtl: builtins: (not just) rs6000: Add builtins for fegetround, feclearexcept and feraiseexcept [PR94193]

This optimizations were originally in glibc, but was removed
and suggested that they were a good fit as gcc builtins[1].

feclearexcept and feraiseexcept were extended (in comparison to the
glibc version) to accept any combination of the accepted flags, not
limited to just one flag bit at a time anymore.

The builtin expanders needs knowledge of the target libc's FE_*
values, so they are limited to expand only to suitable libcs.

[1] https://sourceware.org/legacy-ml/libc-alpha/2020-03/msg00047.html
    https://sourceware.org/legacy-ml/libc-alpha/2020-03/msg00080.html

2020-08-13  Raoni Fassina Firmino  <raoni@linux.ibm.com>

gcc/
PR target/94193
* builtins.cc (expand_builtin_fegetround): New function.
(expand_builtin_feclear_feraise_except): New function.
(expand_builtin): Add cases for BUILT_IN_FEGETROUND,
BUILT_IN_FECLEAREXCEPT and BUILT_IN_FERAISEEXCEPT.
* config/rs6000/rs6000.md (fegetroundsi): New pattern.
(feclearexceptsi): New Pattern.
(feraiseexceptsi): New Pattern.
* doc/extend.texi: Add a new introductory paragraph about the
new builtins.
* doc/md.texi: (fegetround@var{m}): Document new optab.
(feclearexcept@var{m}): Document new optab.
(feraiseexcept@var{m}): Document new optab.
* optabs.def (fegetround_optab): New optab.
(feclearexcept_optab): New optab.
(feraiseexcept_optab): New optab.

gcc/testsuite/
PR target/94193
* gcc.target/powerpc/builtin-feclearexcept-feraiseexcept-1.c: New test.
* gcc.target/powerpc/builtin-feclearexcept-feraiseexcept-2.c: New test.
* gcc.target/powerpc/builtin-fegetround.c: New test.

Signed-off-by: Raoni Fassina Firmino <raoni@linux.ibm.com>
gcc/builtins.cc
gcc/config/rs6000/rs6000.md
gcc/doc/extend.texi
gcc/doc/md.texi
gcc/optabs.def
gcc/testsuite/gcc.target/powerpc/builtin-feclearexcept-feraiseexcept-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/builtin-feclearexcept-feraiseexcept-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/builtin-fegetround.c [new file with mode: 0644]