riscv: improve cost model for loading 64bit constant in rv32
The motivation of this patch is to correct the wrong estimation of the number of instructions needed for loading a 64bit constant in rv32 in the current cost model(riscv_interger_cost). According to the current implementation, if a constant requires more than 3 instructions(riscv_const_insn and riscv_legitimate_constant_p), then the constant will be put into constant pool when expanding gimple to rtl(legitimate_constant_p hook and emit_move_insn). So the inaccurate cost model leads to the suboptimal codegen in rv32 and the wrong estimation part could be corrected through this fix.
e.g. the current codegen for loading 0x839290001 in rv32
lui a5,%hi(.LC0)
lw a0,%lo(.LC0)(a5)
lw a1,%lo(.LC0+4)(a5)
.LC0:
.word
958988289
.word 8
output after this patch
li a0,
958988288
addi a0,a0,1
li a1,8
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_build_integer): Improve some cases
of loading 64bit constants for rv32.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rv32-load-64bit-constant.c: New test.