]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Handle vectorized copysign (x, -1) expansion efficiently
authorXi Ruoyao <xry111@xry111.site>
Mon, 13 Nov 2023 16:17:19 +0000 (00:17 +0800)
committerXi Ruoyao <xry111@xry111.site>
Fri, 17 Nov 2023 11:21:11 +0000 (19:21 +0800)
commitbdf20fdfc342746d1e1785f5aaa36e33897b1574
treebd147f723562223035e0ce07617b4e248b54450b
parent10615c8a10d6b61e813254924d76be728dbd4688
LoongArch: Handle vectorized copysign (x, -1) expansion efficiently

With LSX or LASX, copysign (x[i], -1) (or any negative constant) can be
vectorized using [x]vbitseti.{w/d} instructions to directly set the
signbits.

Inspired by Tamar Christina's "AArch64: Handle copysign (x, -1) expansion
efficiently" (r14-5289).

gcc/ChangeLog:

* config/loongarch/lsx.md (copysign<mode>3): Allow operand[2] to
be an reg_or_vector_same_val_operand.  If it's a const vector
with same negative elements, expand the copysign with a bitset
instruction.  Otherwise, force it into an register.
* config/loongarch/lasx.md (copysign<mode>3): Likewise.

gcc/testsuite/ChangeLog:

* g++.target/loongarch/vect-copysign-negconst.C: New test.
* g++.target/loongarch/vect-copysign-negconst-run.C: New test.
gcc/config/loongarch/lasx.md
gcc/config/loongarch/lsx.md
gcc/testsuite/g++.target/loongarch/vect-copysign-negconst-run.C [new file with mode: 0644]
gcc/testsuite/g++.target/loongarch/vect-copysign-negconst.C [new file with mode: 0644]