https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113033
--- Comment #9 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 256fa7d048d..65a2915329e 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -10770,7 +10770,7 @@ loongarch_expand_vector_init_same (rtx target, rtx vals, unsigned nvar) gcc_unreachable (); } } - temp = gen_reg_rtx (imode); + if (imode == GET_MODE (same)) temp2 = same; else if (GET_MODE_SIZE (imode) >= UNITS_PER_WORD) @@ -10795,7 +10795,8 @@ loongarch_expand_vector_init_same (rtx target, rtx vals, unsigned nvar) else temp2 = lowpart_subreg (imode, same, GET_MODE (same)); } - emit_move_insn (temp, temp2); + + temp = force_reg (imode, temp2); switch (vmode) { I mistakenly thought force_reg is just creating an reg and moving into it (if the operand is not already in reg) but I was wrong.