]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Redundant sign extension instruction optimization.
authorLulu Cheng <chenglulu@loongson.cn>
Wed, 29 Oct 2025 09:55:14 +0000 (17:55 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 7 Nov 2025 01:21:41 +0000 (09:21 +0800)
commitf6bca888663cc8d451b0f01ea459454b2ebc4c81
treee359cd78d16d46e8e1678fa389f55f82a89095c6
parentcbd06e9f66c2d40ff4af7fa648878eaf32928c18
LoongArch: Redundant sign extension instruction optimization.

When the mode of the destination operand selected by the condition
is SImode, explicit sign extension is applied to both selected
source operands, and the destination operand is marked as
sign-extended.

This method can eliminate some of the sign extension instructions
caused by conditional selection optimization.

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_sign_extend_if_subreg_prom_p): Determine if the
current operand is SUBREG and if the source of SUBREG is
the sign-extended value.
(loongarch_expand_conditional_move): Optimize.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/sign-extend-4.c: New test.
* gcc.target/loongarch/sign-extend-5.c: New test.
gcc/config/loongarch/loongarch.cc
gcc/testsuite/gcc.target/loongarch/sign-extend-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/sign-extend-5.c [new file with mode: 0644]