[llvm-bugs] [Bug 28426] New: umulll_overflow with constant powers of two are not well optimized
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jul 5 09:09:07 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28426
Bug ID: 28426
Summary: umulll_overflow with constant powers of two are not
well optimized
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: jmuizelaar at mozilla.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
bool k(unsigned long long i) {
unsigned long long result;
return __builtin_umulll_overflow(i, 4, &result);
}
compiles to:
movl $4, %ecx
movq %rdi, %rax
mulq %rcx
seto %al
retq
A better alternative would be this code:
bool k(unsigned long long i)
{
return i >> (64-2);
}
which compiles to:
shrq $62, %rdi
setne %al
retq
This idiom comes from compiled rust code which does an overflow check when
allocating Vecs so it is quite prevalent.
--
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/20160705/ba7b61ad/attachment.html>
More information about the llvm-bugs
mailing list