https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106586
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 53463 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53463&action=edit Patch (which might depend on other patches) I have a full fix now. The problem I mentioned is a few different issues. First is SINGLE_BIT_MASK_OPERAND is not correct for 32bit for INT_MAX. single_bit_mask_operand and not_single_bit_mask_operand should be using SINGLE_BIT_MASK_OPERAND now too to correct for that also. Next issue is riscv_build_integer_1 should not special case SImode for !TARAGET_64BIT, it is already correct. The next issue is riscv_build_integer_1 needs to do trunc_int_for_mode. And then riscv_move_integer should do that also. Last but not least riscv_emit_int_compare forgot to do trunc_int_for_mode also.