https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106586
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There is still some missing sign extend of the const_int. (insn 17 16 18 4 (set (reg:SI 77) (mem/u/c:SI (lo_sum:SI (reg/f:SI 78) (symbol_ref/u:SI ("*.LC0") [flags 0x82])) [0 S4 A32])) "t89.c":5:16 140 {*movsi_internal} (expr_list:REG_DEAD (reg/f:SI 78) (expr_list:REG_EQUAL (const_int 2147483648 [0x80000000]) (nil)))) Notice the REG_EQUAL. I think the issue is inside riscv_build_integer_1. Specifically this: alt_cost = 1 + riscv_build_integer_1 (alt_codes, value - low_part, mode);