]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Slightly simplify loongarch_block_move_straight
authorXi Ruoyao <xry111@xry111.site>
Thu, 7 Sep 2023 16:29:57 +0000 (00:29 +0800)
committerXi Ruoyao <xry111@xry111.site>
Sat, 9 Sep 2023 06:32:56 +0000 (14:32 +0800)
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.

gcc/config/loongarch/loongarch.cc

index 509ef2b97f1caed8f2406c760803231d7adc9dc4..845fad5a8e8bfc022a5027594939ff30864d2d3a 100644 (file)
@@ -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);