Fix RTL simplifications of FFS, POPCOUNT and PARITY.
authorRoger Sayle <roger@nextmovesoftware.com>
Mon, 27 Feb 2023 17:26:54 +0000 (17:26 +0000)
committerRoger Sayle <roger@nextmovesoftware.com>
Mon, 27 Feb 2023 17:26:54 +0000 (17:26 +0000)
commitab76d71179be6e4e09ee3d5b7e8fa4265717a34c
tree86b831022f05884932a14787489dbd55909e0581
parente5fcf084e381aefe170dcd418dc97e469dacfa91
Fix RTL simplifications of FFS, POPCOUNT and PARITY.

In 2011, the rtl.texi documentation was updated to reflect that the
modes of the RTX unary operations FFS, POPCOUNT and PARITY should
match those of their operands.  Unfortunately, some of the transformations
in simplify-rtx.cc predate this tightening of RTL semantics, and have
not (until now) been updated/fixed.  i.e. The POPCOUNT and PARITY
optimizations were "correct" when I added them back in 2007.

2023-02-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* simplify-rtx.cc (simplify_unary_operation_1) <case FFS>: Avoid
generating FFS with mismatched operand and result modes, by using
an explicit SIGN_EXTEND/ZERO_EXTEND.
<case POPCOUNT>: Likewise, for POPCOUNT of ZERO_EXTEND.
<case PARITY>: Likewise, for PARITY of {ZERO,SIGN}_EXTEND.
gcc/simplify-rtx.cc