* [PATCH] LoongArch: Slightly simplify loongarch_block_move_straight
@ 2023-09-07 16:33 Xi Ruoyao
2023-09-09 6:16 ` chenglulu
0 siblings, 1 reply; 3+ messages in thread
From: Xi Ruoyao @ 2023-09-07 16:33 UTC (permalink / raw)
To: gcc-patches; +Cc: chenglulu, i, xuchenghua, Xi Ruoyao
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_block_move_straight):
Check precondition (delta must be a power of 2) and use
popcount_hwi instead of a homebrew loop.
---
I've not run a full bootstrap with this, but it should be obvious.
Ok for trunk?
gcc/config/loongarch/loongarch.cc | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 509ef2b97f1..845fad5a8e8 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -5225,9 +5225,8 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length,
emit two ld.d/st.d pairs, one ld.w/st.w pair, and one ld.b/st.b
pair. For each load/store pair we use a dedicated register to keep
the pipeline as populated as possible. */
- HOST_WIDE_INT num_reg = length / delta;
- for (delta_cur = delta / 2; delta_cur != 0; delta_cur /= 2)
- num_reg += !!(length & delta_cur);
+ gcc_assert (pow2p_hwi (delta));
+ HOST_WIDE_INT num_reg = length / delta + popcount_hwi (length % delta);
/* Allocate a buffer for the temporary registers. */
regs = XALLOCAVEC (rtx, num_reg);
--
2.42.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Slightly simplify loongarch_block_move_straight
2023-09-07 16:33 [PATCH] LoongArch: Slightly simplify loongarch_block_move_straight Xi Ruoyao
@ 2023-09-09 6:16 ` chenglulu
2023-09-09 7:04 ` Pushed: " Xi Ruoyao
0 siblings, 1 reply; 3+ messages in thread
From: chenglulu @ 2023-09-09 6:16 UTC (permalink / raw)
To: Xi Ruoyao, gcc-patches; +Cc: i, xuchenghua
在 2023/9/8 上午12:33, Xi Ruoyao 写道:
> gcc/ChangeLog:
>
> * config/loongarch/loongarch.cc (loongarch_block_move_straight):
> Check precondition (delta must be a power of 2) and use
> popcount_hwi instead of a homebrew loop.
> ---
>
> I've not run a full bootstrap with this, but it should be obvious.
> Ok for trunk?
LGTM!
Thanks!
>
> gcc/config/loongarch/loongarch.cc | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 509ef2b97f1..845fad5a8e8 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -5225,9 +5225,8 @@ loongarch_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length,
> emit two ld.d/st.d pairs, one ld.w/st.w pair, and one ld.b/st.b
> pair. For each load/store pair we use a dedicated register to keep
> the pipeline as populated as possible. */
> - HOST_WIDE_INT num_reg = length / delta;
> - for (delta_cur = delta / 2; delta_cur != 0; delta_cur /= 2)
> - num_reg += !!(length & delta_cur);
> + gcc_assert (pow2p_hwi (delta));
> + HOST_WIDE_INT num_reg = length / delta + popcount_hwi (length % delta);
>
> /* Allocate a buffer for the temporary registers. */
> regs = XALLOCAVEC (rtx, num_reg);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Pushed: [PATCH] LoongArch: Slightly simplify loongarch_block_move_straight
2023-09-09 6:16 ` chenglulu
@ 2023-09-09 7:04 ` Xi Ruoyao
0 siblings, 0 replies; 3+ messages in thread
From: Xi Ruoyao @ 2023-09-09 7:04 UTC (permalink / raw)
To: chenglulu, gcc-patches; +Cc: i, xuchenghua
Pushed r14-3819.
On Sat, 2023-09-09 at 14:16 +0800, chenglulu wrote:
>
> 在 2023/9/8 上午12:33, Xi Ruoyao 写道:
> > gcc/ChangeLog:
> >
> > * config/loongarch/loongarch.cc
> > (loongarch_block_move_straight):
> > Check precondition (delta must be a power of 2) and use
> > popcount_hwi instead of a homebrew loop.
> > ---
> >
> > I've not run a full bootstrap with this, but it should be obvious.
> > Ok for trunk?
>
> LGTM!
>
> Thanks!
>
> >
> > gcc/config/loongarch/loongarch.cc | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/gcc/config/loongarch/loongarch.cc
> > b/gcc/config/loongarch/loongarch.cc
> > index 509ef2b97f1..845fad5a8e8 100644
> > --- a/gcc/config/loongarch/loongarch.cc
> > +++ b/gcc/config/loongarch/loongarch.cc
> > @@ -5225,9 +5225,8 @@ loongarch_block_move_straight (rtx dest, rtx
> > src, HOST_WIDE_INT length,
> > emit two ld.d/st.d pairs, one ld.w/st.w pair, and one
> > ld.b/st.b
> > pair. For each load/store pair we use a dedicated register
> > to keep
> > the pipeline as populated as possible. */
> > - HOST_WIDE_INT num_reg = length / delta;
> > - for (delta_cur = delta / 2; delta_cur != 0; delta_cur /= 2)
> > - num_reg += !!(length & delta_cur);
> > + gcc_assert (pow2p_hwi (delta));
> > + HOST_WIDE_INT num_reg = length / delta + popcount_hwi (length %
> > delta);
> >
> > /* Allocate a buffer for the temporary registers. */
> > regs = XALLOCAVEC (rtx, num_reg);
>
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-09 7:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07 16:33 [PATCH] LoongArch: Slightly simplify loongarch_block_move_straight Xi Ruoyao
2023-09-09 6:16 ` chenglulu
2023-09-09 7:04 ` Pushed: " 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).