]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add RTX codes for BITREVERSE and COPYSIGN.
authorRoger Sayle <roger@nextmovesoftware.com>
Tue, 6 Jun 2023 23:32:51 +0000 (00:32 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Tue, 6 Jun 2023 23:32:51 +0000 (00:32 +0100)
commit6160572f8d243cb613ee0290fdc8580f1761d805
tree4478298c304dfbedd605995d0af2d84f356af9a1
parent585c660f041c57694a61b3e65085af5a54431be4
Add RTX codes for BITREVERSE and COPYSIGN.

An analysis of backend UNSPECs reveals that two of the most common UNSPECs
across target backends are for copysign and bit reversal.  This patch
adds RTX codes for these expressions to allow their representation to
be standardized, and them to optimized by the middle-end RTL optimizers.

2023-06-07  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* doc/rtl.texi (bitreverse, copysign): Document new RTX codes.
* rtl.def (BITREVERSE, COPYSIGN): Define new RTX codes.
* simplify-rtx.cc (simplify_unary_operation_1): Optimize
NOT (BITREVERSE x) as BITREVERSE (NOT x).
Optimize POPCOUNT (BITREVERSE x) as POPCOUNT x.
Optimize PARITY (BITREVERSE x) as PARITY x.
Optimize BITREVERSE (BITREVERSE x) as x.
(simplify_const_unary_operation) <case BITREVERSE>: Evaluate
BITREVERSE of a constant integer at compile-time.
(simplify_binary_operation_1) <case COPYSIGN>:  Optimize
COPY_SIGN (x, x) as x.  Optimize COPYSIGN (x, C) as ABS x
or NEG (ABS x) for constant C.  Optimize COPYSIGN (ABS x, y)
and COPYSIGN (NEG x, y) as COPYSIGN (x, y).
Optimize COPYSIGN (x, ABS y) as ABS x.
Optimize COPYSIGN (COPYSIGN (x, y), z) as COPYSIGN (x, z).
Optimize COPYSIGN (x, COPYSIGN (y, z)) as COPYSIGN (x, z).
(simplify_const_binary_operation): Evaluate COPYSIGN of constant
arguments at compile-time.
gcc/doc/rtl.texi
gcc/rtl.def
gcc/simplify-rtx.cc