]> git.ipfire.org Git - thirdparty/gcc.git/commit
simplify-rtx: Transform (xor (and (xor A B) C) B) with C const
authorSegher Boessenkool <segher@kernel.crashing.org>
Thu, 10 Nov 2016 00:32:43 +0000 (01:32 +0100)
committerSegher Boessenkool <segher@gcc.gnu.org>
Thu, 10 Nov 2016 00:32:43 +0000 (01:32 +0100)
commita62436c0a505155fc8becac07a8c0abe2c265bfe
treebb6f4efa2648eb51dc815e233e1459b00835762f
parenta84a4f0b87c7ff9836a5b7c030be43aec6126966
simplify-rtx: Transform (xor (and (xor A B) C) B) with C const

match.pd transforms (A&C)|(B&~C) to ((A^B)&C)^B, which is fewer
operations if C is not const (and it is not on simple tests at least,
this transform is done very early already).

Various processors have "insert" instructions that can do this, but
combine cannot build those from the xor-and-xor, especially it has no
chance at all to do that if A or B or multiple instructions as well
(on PowerPC, the rl[wd]imi instructions can do this with together with
a rotate, or a simple shift with appropriate C; other ISAs have similar
insns).

This patch makes RTL simplify transform (xor (and (xor A B) C) B) back
to (ior (and A C) (and B ~C)) for constant C (and similar with A instead
of B for that last term).

* simplify-rtx.c (simplify_binary_operation_1): Simplify
(xor (and (xor A B) C) B) to (ior (and A C) (and B ~C)) and
(xor (and (xor A B) C) A) to (ior (and A ~C) (and B C)) if C
is a const_int.

From-SVN: r242031
gcc/ChangeLog
gcc/simplify-rtx.c