[llvm-bugs] [Bug 38264] New: Missed optimizations for comparison with multiplications
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jul 22 10:59:32 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38264
Bug ID: 38264
Summary: Missed optimizations for comparison with
multiplications
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
Hello,
int f2(int x, int y, int z) {
int tmp = y--;
if (tmp * x > x * y)
return 1;
return 0;
}
Current codegen:
f2(int, int, int): # @f2(int, int, int)
lea ecx, [rsi - 1]
imul esi, edi
imul ecx, edi
xor eax, eax
cmp esi, ecx
setg al
ret
GCC:
f2(int, int, int):
xor eax, eax
test edi, edi
setg al
ret
/////////////////////
int f2(int x, int y, int z) {
if ((y-1) * x > x * y)
return 1;
return 0;
}
f2(int, int, int): # @f2(int, int, int)
lea ecx, [rsi - 1]
imul ecx, edi
imul esi, edi
xor eax, eax
cmp ecx, esi
setg al
ret
GCC:
f2(int, int, int):
mov eax, edi
shr eax, 31
ret
For unsigned case - Clang:
f2(unsigned int, unsigned int, unsigned int): # @f2(unsigned int, unsigned int,
unsigned int)
lea ecx, [rsi - 1]
imul ecx, edi
imul esi, edi
xor eax, eax
cmp ecx, esi
seta al
ret
GCC (one multiplication is eliminated):
f2(unsigned int, unsigned int, unsigned int):
sub esi, 1
xor eax, eax
imul esi, edi
add esi, edi
setc al
ret
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180722/99230ccb/attachment.html>
More information about the llvm-bugs
mailing list