]> gcc.gnu.org Git - gcc.git/commit
LoongArch: New options -mrecip and -mrecip= with ffast-math.
authorJiahao Xu <xujiahao@loongson.cn>
Wed, 6 Dec 2023 07:04:52 +0000 (15:04 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 8 Dec 2023 08:29:50 +0000 (16:29 +0800)
commit9a07bc477e197ef935679bacd0a923a98c006b2a
tree2e483a41d7dfc256df3685982b90ac506dec424d
parent276c7618bf41bc2f03cf4b22c24b23c8ba29eca4
LoongArch: New options -mrecip and -mrecip= with ffast-math.

When both the -mrecip and -mfrecipe options are enabled, use approximate reciprocal
instructions and approximate reciprocal square root instructions with additional
Newton-Raphson steps to implement single precision floating-point division, square
root and reciprocal square root operations, for a better performance.

gcc/ChangeLog:

* config/loongarch/genopts/loongarch.opt.in (recip_mask): New variable.
(-mrecip, -mrecip): New options.
* config/loongarch/lasx.md (div<mode>3): New expander.
(*div<mode>3): Rename.
(sqrt<mode>2): New expander.
(*sqrt<mode>2): Rename.
(rsqrt<mode>2): New expander.
* config/loongarch/loongarch-protos.h (loongarch_emit_swrsqrtsf): New prototype.
(loongarch_emit_swdivsf): Ditto.
* config/loongarch/loongarch.cc (loongarch_option_override_internal): Set
recip_mask for -mrecip and -mrecip= options.
(loongarch_emit_swrsqrtsf): New function.
(loongarch_emit_swdivsf): Ditto.
* config/loongarch/loongarch.h (RECIP_MASK_NONE, RECIP_MASK_DIV, RECIP_MASK_SQRT
RECIP_MASK_RSQRT, RECIP_MASK_VEC_DIV, RECIP_MASK_VEC_SQRT, RECIP_MASK_VEC_RSQRT
RECIP_MASK_ALL): New bitmasks.
(TARGET_RECIP_DIV, TARGET_RECIP_SQRT, TARGET_RECIP_RSQRT, TARGET_RECIP_VEC_DIV
TARGET_RECIP_VEC_SQRT, TARGET_RECIP_VEC_RSQRT): New tests.
* config/loongarch/loongarch.md (sqrt<mode>2): New expander.
(*sqrt<mode>2): Rename.
(rsqrt<mode>2): New expander.
* config/loongarch/loongarch.opt (recip_mask): New variable.
(-mrecip, -mrecip): New options.
* config/loongarch/lsx.md (div<mode>3): New expander.
(*div<mode>3): Rename.
(sqrt<mode>2): New expander.
(*sqrt<mode>2): Rename.
(rsqrt<mode>2): New expander.
* config/loongarch/predicates.md (reg_or_vecotr_1_operand): New predicate.
* doc/invoke.texi (LoongArch Options): Document new options.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/divf.c: New test.
* gcc.target/loongarch/recip-divf.c: New test.
* gcc.target/loongarch/recip-sqrtf.c: New test.
* gcc.target/loongarch/sqrtf.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-divf.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-recip-divf.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-recip-sqrtf.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-recip.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-sqrtf.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-divf.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-recip-divf.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-recip-sqrtf.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-recip.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-sqrtf.c: New test.
24 files changed:
gcc/config/loongarch/genopts/loongarch.opt.in
gcc/config/loongarch/lasx.md
gcc/config/loongarch/loongarch-protos.h
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.h
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/loongarch.opt
gcc/config/loongarch/lsx.md
gcc/config/loongarch/predicates.md
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/loongarch/divf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/recip-divf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/recip-sqrtf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/sqrtf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-divf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-recip-divf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-recip-sqrtf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-recip.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lasx/lasx-sqrtf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-divf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-recip-divf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-recip-sqrtf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-recip.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/vector/lsx/lsx-sqrtf.c [new file with mode: 0644]
This page took 0.070602 seconds and 5 git commands to generate.