[PATCH] simplify-rtx: Two easy pieces.

Roger Sayle roger@nextmovesoftware.com
Fri Jun 19 20:42:54 GMT 2020


My recent patch to add scalar integer simplification unit tests to simplify_rtx_c_tests
identified two "trivial" corner cases that could be improved in simplify-rtx.c.
I don't believe that either case can currently be triggered from GCC current
front-end/back-end combinations, but hopefully the reviewer agrees these
changes are simple/safe enough.

Although it makes no sense to ever see a BImode ROTATE, the current ordering
of transformations in simplify_binary_operation_1 converts (rotate:bi (reg:bi) 0) to
(rotatert:bi (reg:bi) 1), which then doesn't get simplified away.  Rather than teach
the middle-end that any hypothetical ROTATE or ROTATERT of a BImode value is a
no-op, a more realistic invariant is that any rotate by const0_rtx is already canonical.

Optimizing "parity of parity" matches the tree constant folding transformation pending
review.  Alas, the only mentions of PARITY in GCC's official backend machine descriptions
are in expanders, so the middle-end's RTL optimizers never see a PARITY to simplify.
A test can be added to test_scalar_int_ops once that patch is reviewed/approved.

This patch has been tested with "make bootstrap" and "make -k check"
on x86_64-pc-linux-gnu with no regressions.


2020-06-19  Roger Sayle  <roger@nextmovesoftware.com>

        * simplify-rtx.c (simplify_unary_operation_1): Simplify
        (parity (parity x)) as (parity x), i.e. PARITY is idempotent.
        (simplify_binary_operation_1): Don't canonicalize rotations
        by zero bits, these get simplified away.


Thanks in advance,
Roger
--
Roger Sayle
NextMove Software
Cambridge, UK

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patchd.txt
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200619/14e09453/attachment.txt>


More information about the Gcc-patches mailing list