http://llvm.org/bugs/show_bug.cgi?id=21929
Bug ID: 21929
Summary: Missed optimisation for modulo 2
Product: new-bugs
Version: 3.4
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
See Godbolt snippet here: http://goo.gl/imHtck
inline int intMod(int x, int y)
{
const int r = x % y;
if(r < 0)
return y + r;
else
return r;
}
int f(int x)
{
return intMod(x, 2); // Should this optimse to x & 0x1 ?
//return x & 0x1;
}
Compiles to:
f(int): # @f(int)
movl %edi, %eax
shrl $31, %eax
addl %edi, %eax
andl $-2, %eax
subl %eax, %edi
movl %edi, %eax
shrl $31, %eax
leal (%rdi,%rax,2), %eax
ret
It seems to be valid to make the optimisation intMod(x, 2) = x & 0x1,
which LLVM doesn't do.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs