[llvm-bugs] [Bug 38649] New: multiply lowering of divide-by-constant doesn't occur on haswell
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 20 13:50:57 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38649
Bug ID: 38649
Summary: multiply lowering of divide-by-constant doesn't occur
on haswell
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: jorg.brown at gmail.com
CC: llvm-bugs at lists.llvm.org
Source:
struct SecsAndTicks {
uint64_t seconds;
uint32_t ticks;
};
SecsAndTicks DivBy4Bill(uint64_t tix) {
return {tix / 4000000000,
uint32_t(tix % 4000000000)};
}
x86-64 codegen:
movq %rdi, %rax
shrq $11, %rax
movabsq $4835703278458517, %rcx # imm = 0x112E0BE826D695
mulq %rcx
shrq $9, %rdx
imull $-294967296, %edx, %eax # imm = 0xEE6B2800
subl %eax, %edi
movq %rdx, %rax
movl %edi, %edx
retq
march=haswell codegen:
movl $4000000000, %ecx # imm = 0xEE6B2800
movq %rdi, %rax
shrq $32, %rax
je .LBB0_1
xorl %edx, %edx
movq %rdi, %rax
divq %rcx
retq
.LBB0_1:
xorl %edx, %edx
movl %edi, %eax
divl %ecx
retq
See https://godbolt.org/g/qGTDGN for repro
--
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/20180820/211045fd/attachment.html>
More information about the llvm-bugs
mailing list