Simplify (a ^ b) & ((b ^ c) ^ a) --> (a ^ b) & ~c. int f(int a, int b, int c) { return (a ^ b) & ((b ^ c) ^ a); }
Code without the patch: mov eax,edx xor eax,esi xor eax,edi xor edi,esi and eax,edi ret Code with the patch: xor edi,esi andn eax,edx,edi ret Simplify (a ^ b) | ((b ^ c) ^ a) --> (a ^ b) | c. int g(int a, int b, int c) { return (a ^ b) | ((b ^ c) ^ a); } Code without the patch: mov eax,edx xor eax,esi xor eax,edi xor edi,esi or eax,edi ret Code with the patch: xor edi,esi mov eax,edi or eax,edx ret This fixes PR96671. Tested on x86_64-pc-linux-gnu.
0001-Optimize-two-patterns-with-three-xors.patch
Description: 0001-Optimize-two-patterns-with-three-xors.patch