public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/2] loongarch: improve code generation for integer division
@ 2022-07-07  2:23 Xi Ruoyao
  2022-07-07  2:26 ` [PATCH 1/2] loongarch: add alternatives for idiv insns to improve code generation Xi Ruoyao
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Xi Ruoyao @ 2022-07-07  2:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: Lulu Cheng, Chenghua Xu, Wang Xuerui

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

-- 
2.37.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-10  3:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07  2:23 [PATCH 0/2] loongarch: improve code generation for integer division Xi Ruoyao
2022-07-07  2:26 ` [PATCH 1/2] loongarch: add alternatives for idiv insns to improve code generation Xi Ruoyao
2022-07-07  2:29 ` [PATCH 2/2] loongarch: avoid unnecessary sign-extend after 32-bit division Xi Ruoyao
2022-07-08  1:23 ` [PATCH 0/2] loongarch: improve code generation for integer division Lulu Cheng
2022-07-10  2:20 ` Lulu Cheng
2022-07-10  3:44   ` Xi Ruoyao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).