LoongArch: Provide fmin/fmax RTL pattern
authorXi Ruoyao <xry111@xry111.site>
Tue, 16 Aug 2022 07:34:36 +0000 (15:34 +0800)
committerXi Ruoyao <xry111@xry111.site>
Wed, 17 Aug 2022 08:08:05 +0000 (16:08 +0800)
commit3cab897a67af120aa18efa7ddd7ee49b9a29e5dd
treeb4e16fddf5234b3fd5e61c1a3980b736259878a5
parent80f78716c2c7ce1b7f96077c35c1dd474a2086a2
LoongArch: Provide fmin/fmax RTL pattern

We already had smin/smax RTL pattern using fmin/fmax instruction.  But
for smin/smax, it's unspecified what will happen if either operand is
NaN.  So we would generate calls to libc fmin/fmax functions with
-fno-finite-math-only (the default for all optimization levels expect
-Ofast).

But, LoongArch fmin/fmax instruction is IEEE-754-2008 conformant so we
can also use the instruction for fmin/fmax pattern and avoid the library
function call.

gcc/ChangeLog:

* config/loongarch/loongarch.md (fmax<mode>3): New RTL pattern.
(fmin<mode>3): Likewise.

gcc/testsuite/ChangeLog:

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