LoongArch: Add flogb.{s,d} instructions and expand logb{sf,df}2
authorXi Ruoyao <xry111@xry111.site>
Tue, 8 Nov 2022 05:42:20 +0000 (13:42 +0800)
committerXi Ruoyao <xry111@xry111.site>
Sat, 12 Nov 2022 07:01:13 +0000 (15:01 +0800)
commitf5225dbf5cf2a57ed5a2073b1a90a854093d063e
tree05d30315007f73e4d32e45a0097b7d999bc25519
parentd26c757b2ec22d2d752af94908ce54a1266cca01
LoongArch: Add flogb.{s,d} instructions and expand logb{sf,df}2

On LoongArch, flogb instructions extract the exponent of a non-negative
floating point value, but produces NaN for negative values.  So we need
to add a fabs instruction when we expand logb.

gcc/ChangeLog:

* config/loongarch/loongarch.md (UNSPEC_FLOGB): New unspec.
(type): Add flogb.
(logb_non_negative<mode>2): New instruction template.
(logb<mode>2): New define_expand.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/flogb.c: New test.
gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/flogb.c [new file with mode: 0644]