forked from iains/gcc-14-branch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LoongArch: Provide fmin/fmax RTL pattern for vectors
We already had smin/smax RTL pattern using vfmin/vfmax instructions. But for smin/smax, it's unspecified what will happen if either operand contains any NaN operands. So we would not vectorize the loop with -fno-finite-math-only (the default for all optimization levels expect -Ofast). But, LoongArch vfmin/vfmax instruction is IEEE-754-2008 conformant so we can also use them and vectorize the loop. gcc/ChangeLog: * config/loongarch/simd.md (fmax<mode>3): New define_insn. (fmin<mode>3): Likewise. (reduc_fmax_scal_<mode>3): New define_expand. (reduc_fmin_scal_<mode>3): Likewise. gcc/testsuite/ChangeLog: * gcc.target/loongarch/vfmax-vfmin.c: New test.
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O2 -mtune=la464 -mlasx" } */ | ||
/* { dg-final { scan-assembler "\tvfmin\\.d" } } */ | ||
/* { dg-final { scan-assembler "\tvfmax\\.d" } } */ | ||
/* { dg-final { scan-assembler "\txvfmin\\.d" } } */ | ||
/* { dg-final { scan-assembler "\txvfmax\\.d" } } */ | ||
/* { dg-final { scan-assembler "\tvfmin\\.s" } } */ | ||
/* { dg-final { scan-assembler "\tvfmax\\.s" } } */ | ||
/* { dg-final { scan-assembler "\txvfmin\\.s" } } */ | ||
/* { dg-final { scan-assembler "\txvfmax\\.s" } } */ | ||
|
||
#define T(OP) __typeof__ (__builtin_##OP (0, 0)) | ||
|
||
#define TEST(OP, LEN) \ | ||
void \ | ||
test_##OP##LEN (T (OP) *restrict dest, \ | ||
const T (OP) *restrict src1, \ | ||
const T (OP) *restrict src2) \ | ||
{ \ | ||
for (int i = 0; i < LEN / sizeof (T(OP)); i++) \ | ||
dest[i] = __builtin_##OP (src1[i], src2[i]); \ | ||
} | ||
|
||
TEST(fmin, 16) | ||
TEST(fmax, 16) | ||
TEST(fmin, 32) | ||
TEST(fmax, 32) | ||
TEST(fminf, 16) | ||
TEST(fmaxf, 16) | ||
TEST(fminf, 32) | ||
TEST(fmaxf, 32) |