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. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-32} with no new failures. Ok for mainline? 2023-05-06 Roger Sayle 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) : Evaluate BITREVERSE of a constant integer at compile-time. (simplify_binary_operation_1) : 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. * wide-int.cc (wide_int_storage::bitreverse): Provide a wide_int implementation, based upon bswap implementation. * wide-int.g (wide_int_storage::bitreverse): Prototype here. Thanks in advance, Roger --