diff options
author | Matevos Mehrabyan <matevosmehrabyan@gmail.com> | 2023-04-28 14:01:30 -0600 |
---|---|---|
committer | Jeff Law <jlaw@ventanamicro> | 2023-04-28 14:03:32 -0600 |
commit | 065be0ffbcd676b635d492f4679e635b6ece4fe4 (patch) | |
tree | 0a3f0fc0c100f4fec7f10335c0cc42cc54a56cdf /libcpp/init.cc | |
parent | d9df45a66b2c8f543106be0a2387bbe6195b00a6 (diff) | |
download | gcc-065be0ffbcd676b635d492f4679e635b6ece4fe4.zip gcc-065be0ffbcd676b635d492f4679e635b6ece4fe4.tar.gz gcc-065be0ffbcd676b635d492f4679e635b6ece4fe4.tar.bz2 |
RISC-V: Add divmod expansion support
Hi all,
If we have division and remainder calculations with the same operands:
a = b / c;
d = b % c;
We can replace the calculation of remainder with multiplication +
subtraction, using the result from the previous division:
a = b / c;
d = a * c;
d = b - d;
Which will be faster.
Currently, it isn't done for RISC-V.
I've added an expander for DIVMOD which replaces 'rem' with 'mul + sub'.
Best regards,
Matevos.
gcc/ChangeLog:
* config/riscv/iterators.md (only_div, paired_mod): New iterators.
(u): Add div/udiv cases.
* config/riscv/riscv-protos.h (riscv_use_divmod_expander): Prototype.
* config/riscv/riscv.cc (struct riscv_tune_param): Add field for
divmod expansion.
(rocket_tune_info, sifive_7_tune_info): Initialize new field.
(thead_c906_tune_info): Likewise.
(optimize_size_tune_info): Likewise.
(riscv_use_divmod_expander): New function.
* config/riscv/riscv.md (<u>divmod<mode>4): New expander.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/divmod-1.c: New testcase.
* gcc.target/riscv/divmod-2.c: New testcase.
Diffstat (limited to 'libcpp/init.cc')
0 files changed, 0 insertions, 0 deletions