This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] simplify-rtx: Transform (xor (and (xor A B) C) B) with C const
On Wed, Nov 09, 2016 at 10:27:35PM +0100, Bernd Schmidt wrote:
> On 11/09/2016 10:13 PM, Segher Boessenkool wrote:
> > * 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) B) to (ior (and A ~C) (and B C)) if C
> > is a const_int.
>
> I think one of the xors should have A as the second operand.
The second, thanks for spotting it.
> >+ /* If we have (xor (and (xor A B) C) A) with C a constant we can
> >instead
> >+ do (ior (and A ~C) (and B C)) which is a machine instruction on
> >some
> >+ machines, and also has shorter instruction path length. */
> >+ if (GET_CODE (op0) == AND
>
> Comments doesn't line up with the if/else on my monitor; could be email
> damage but please check.
I messed it up (had // comments first, whoops).
> Other than that, I think it does qualify as a simplification (or at
> least an improvement), so OK. Would be nice to check for it with a testcase.
I'll do a PowerPC-specific testcase for all rl[wd]* next week. rl[wd]imi
will show this xor-xor thing (half of all possible insns were not optimised
before this patch). Is that enough?
Segher