https://bugs.llvm.org/show_bug.cgi?id=38929
Bug ID: 38929
Summary: Swap binop operands to avoid useless move before
return
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedb...@nondot.org
Reporter: david.bolvan...@gmail.com
CC: llvm-bugs@lists.llvm.org
unsigned f(unsigned x, unsigned y) {
int p = (~x & y) | ~(x | y);
// p =(x ^ y) | ~(x | y);
return p;
}
Clang:
f(unsigned int, unsigned int): # @f(unsigned
int, unsigned int)
mov eax, edi
not eax
and eax, esi
or esi, edi
not esi
or esi, eax // or eax, edi
mov eax, esi // not needed
ret
GCC:
f(unsigned int, unsigned int):
mov eax, edi
or edi, esi
not eax
not edi
and eax, esi
or eax, edi
ret
+ same for xor, etc...
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs