On Sun, 2022-07-10 at 10:20 +0800, Lulu Cheng wrote: > > 在 2022/7/7 上午10:23, Xi Ruoyao 写道: > > We were generating some unnecessary instructions for integer > > division. > > These two patches improve the code generation to compile > > > > template <class T> T div(T a, T b) { return a / b; } > > > > into a single division instruction (along with a return instruction > > of > > course) as we expected for T in {int32_t, uint32_t, int64_t}. > > > > Bootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk? > > > > Xi Ruoyao (2): > > loongarch: add alternatives for idiv insns to improve code > > generation > > loongarch: avoid unnecessary sign-extend after 32-bit division > > > > gcc/config/loongarch/loongarch-protos.h | 1 + > > gcc/config/loongarch/loongarch.cc | 2 +- > > gcc/config/loongarch/loongarch.md | 34 ++++++++++++++++-- > > ---- > > gcc/testsuite/gcc.target/loongarch/div-1.c | 9 ++++++ > > gcc/testsuite/gcc.target/loongarch/div-2.c | 9 ++++++ > > gcc/testsuite/gcc.target/loongarch/div-3.c | 9 ++++++ > > gcc/testsuite/gcc.target/loongarch/div-4.c | 9 ++++++ > > 7 files changed, 63 insertions(+), 10 deletions(-) > > create mode 100644 gcc/testsuite/gcc.target/loongarch/div-1.c > > create mode 100644 gcc/testsuite/gcc.target/loongarch/div-2.c > > create mode 100644 gcc/testsuite/gcc.target/loongarch/div-3.c > > create mode 100644 gcc/testsuite/gcc.target/loongarch/div-4.c > > > LGTM and spec has been tested. > > Thanks!
Pushed r13-1592 and r13-1593. -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University