LoongArch: Add fscaleb.{s,d} instructions as ldexp{sf,df}3
authorXi Ruoyao <xry111@xry111.site>
Tue, 8 Nov 2022 04:14:35 +0000 (12:14 +0800)
committerXi Ruoyao <xry111@xry111.site>
Sat, 12 Nov 2022 07:01:13 +0000 (15:01 +0800)
commitd26c757b2ec22d2d752af94908ce54a1266cca01
tree975a8a0119a80e4550f7b35573e59b7aa0da5926
parent51a233b97cc9c51e63f03f2f5554e905f3f6c054
LoongArch: Add fscaleb.{s,d} instructions as ldexp{sf,df}3

This allows optimizing __builtin_ldexp{,f} and __builtin_scalbn{,f} with
-fno-math-errno.

IMODE is added because we can't hard code SI for operand 2: fscaleb.d
instruction always take the high half of both source registers into
account.  See my_ldexp_long in the test case.

gcc/ChangeLog:

* config/loongarch/loongarch.md (UNSPEC_FSCALEB): New unspec.
(type): Add fscaleb.
(IMODE): New mode attr.
(ldexp<mode>3): New instruction template.

gcc/testsuite/ChangeLog:

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