Simplify
((b | c) & a) | b
to 
(a & c) | b.

This fixes PR96679.

Tested on x86_64-pc-linux-gnu.

int f(int a, int b, int c)
{
    return ((b | c) & a) | b;
}

Code without the patch:
or     edx,esi
and    edx,edi
mov    eax,edx
or     eax,esi
ret

Code with the patch:
and    edi,edx
mov    eax,edi
or     eax,esi
ret

Eugene

Attachment: 0001-Optimize-or-and-or-pattern-to-and-or.patch
Description: 0001-Optimize-or-and-or-pattern-to-and-or.patch

Reply via email to