Ensure that only one register is used when loading immediate values.
The original immediate value load is handled through virtual
registers, resulting in the following load operation
(0x1234567890abcdef):
lu12i.w $r4,-456004 # 0xfffffffffff90abc
or $r12,$r0,$r0
ori $r4,$r4,3567
lu32i.d $r12,0x45678
lu32i.d $r4,0
or $r4,$r4,$r12
lu52i.d $r4,$r4,0x123
The optimized sequence is as follows:
lu12i.w $r4,-456004 # 0xfffffffffff90abc
ori $r4,$r4,3567
lu32i.d $r4,0x45678
lu52i.d $r4,$r4,0x123
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_move_integer):
No new virtual register is allocated during immediate load.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/imm-load.c: Modify.
x = GEN_INT (codes[0].value);
for (i = 1; i < num_ops; i++)
{
- if (!can_create_pseudo_p ())
- {
- emit_insn (gen_rtx_SET (temp, x));
- x = temp;
- }
- else
- x = force_reg (mode, x);
+ emit_insn (gen_rtx_SET (temp, x));
+ x = temp;
set_unique_reg_note (get_last_insn (), REG_EQUAL,
GEN_INT (codes[i-1].curr_value));
{
return 0x1234567890abcdef;
}
-/* { dg-final { scan-rtl-dump-times "scanning new insn with uid" 6 "split1" } } */
+/* { dg-final { scan-rtl-dump-times "scanning new insn with uid" 4 "split1" } } */