match.pd: Optimize (x & y) ^ (x | y)
Jakub Jelinek
jakub@redhat.com
Thu Jun 11 11:18:00 GMT 2015
On Thu, Jun 11, 2015 at 01:04:32PM +0200, Marek Polacek wrote:
> This patch introduces a new pattern for the match-and-simplify
> machinery.
>
> I have verified this transformation on a toy testcase (tried x and y
> in the range [-1000,1000]) and it does a correct thing for all integers.
>
> The asm diff for fn1 is
> - andl %esi, %eax
> - orl %edi, %esi
> so clearly a win.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
What about some nop type conversions in between?
int
fn1 (unsigned int x, unsigned int y)
{
int a = x;
int b = y;
unsigned int c = x & y;
int d = a | b;
return (int) (c ^ d);
}
? Also wonder, if some testcases for match.pd shouldn't be
in separate statements so that they don't test the GENERIC folding,
but GIMPLE folding.
Jakub
More information about the Gcc-patches
mailing list