-
- Downloads
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.
Showing
- gcc/config/riscv/iterators.md 6 additions, 0 deletionsgcc/config/riscv/iterators.md
- gcc/config/riscv/riscv-protos.h 1 addition, 0 deletionsgcc/config/riscv/riscv-protos.h
- gcc/config/riscv/riscv.cc 15 additions, 0 deletionsgcc/config/riscv/riscv.cc
- gcc/config/riscv/riscv.md 16 additions, 0 deletionsgcc/config/riscv/riscv.md
- gcc/testsuite/gcc.target/riscv/divmod-1.c 11 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/divmod-1.c
- gcc/testsuite/gcc.target/riscv/divmod-2.c 16 additions, 0 deletionsgcc/testsuite/gcc.target/riscv/divmod-2.c
Loading
Please register or sign in to comment