https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97417
Levy <admin at levyhsu dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |admin at levyhsu dot com --- Comment #6 from Levy <admin at levyhsu dot com> --- Hi Jim Levy from StarFive. Adding following code to the head of riscv_legitimize_move() according to your reply seems to solve the problem: if(mode == QImode && MEM_P (src) && REG_P (dest)) { rtx temp_reg; if (TARGET_64BIT) { temp_reg = gen_reg_rtx (DImode); emit_insn(gen_zero_extendqidi2(temp_reg, src)); } else { temp_reg = gen_reg_rtx (SImode); emit_insn(gen_zero_extendqisi2(temp_reg, src)); } riscv_emit_move(dest, gen_rtx_SUBREG(QImode,temp_reg,0)); return true; } same foo.c will produce: foo: lui a5,%hi(active) lbu a5,%lo(active)(a5) li a0,42 bne a5,zero,.L6 ret .L6: li a0,-42 ret .size foo, .-foo .ident "GCC: (GNU) 10.2.0" Not sure if I'm doing it right, especially for 64bit DImode because I've only been with gcc for a month. Just wonder if you have time after Monday's compiler meeting so we may discuss movsi, movhi and MEM to MEM copy.