]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Optimize immediate load.
authorLulu Cheng <chenglulu@loongson.cn>
Thu, 17 Nov 2022 09:08:36 +0000 (17:08 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Mon, 28 Nov 2022 02:38:02 +0000 (10:38 +0800)
commitbe591d00ed6cf8ac13850d5490749651acf10139
tree19a0c705f4224595bb40e7b0712fab1d965d9dda
parenta1ecc5600464f6a62faab246d522b6328badda90
LoongArch: Optimize immediate load.

The immediate number is split in the Split pass, not in the expand pass.

Because loop2_invariant pass will extract the instructions that do not change
in the loop out of the loop, some instructions will not meet the extraction
conditions if the machine performs immediate decomposition while expand pass,
so the immediate decomposition will be transferred to the split process.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (enum loongarch_load_imm_method):
Remove the member METHOD_INSV that is not currently used.
(struct loongarch_integer_op): Define a new member curr_value,
that records the value of the number stored in the destination
register immediately after the current instruction has run.
(loongarch_build_integer): Assign a value to the curr_value member variable.
(loongarch_move_integer): Adds information for the immediate load instruction.
* config/loongarch/loongarch.md (*movdi_32bit): Redefine as define_insn_and_split.
(*movdi_64bit): Likewise.
(*movsi_internal): Likewise.
(*movhi_internal): Likewise.
* config/loongarch/predicates.md: Return true as long as it is CONST_INT, ensure
that the immediate number is not optimized by decomposition during expand
optimization loop.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/imm-load.c: New test.
* gcc.target/loongarch/imm-load1.c: New test.
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/predicates.md
gcc/testsuite/gcc.target/loongarch/imm-load.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/imm-load1.c [new file with mode: 0644]