aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2023-09-08 00:29:57 +0800
committerXi Ruoyao <xry111@xry111.site>2023-09-09 14:32:56 +0800
commitc0bb7a6f39e58717d34c9459586c0b1d5db16d89 (patch)
treeeba381eda395a84f083c6d6080a7442e110e06d7 /gcc
parent35adc54b55aa199f17e2c84e382792e424b6171e (diff)
downloadgcc-c0bb7a6f39e58717d34c9459586c0b1d5db16d89.zip
gcc-c0bb7a6f39e58717d34c9459586c0b1d5db16d89.tar.gz
gcc-c0bb7a6f39e58717d34c9459586c0b1d5db16d89.tar.bz2
LoongArch: Slightly simplify loongarch_block_move_straight
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/loongarch/loongarch.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 509ef2b..845fad5 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);