LLVM Chapter 9 reduction
64-by-32 unsigned divide from hi:lo pair
File: udiv_hilo32_x86.ll
Issue:
- LLVM does not reduce a
(zext hi << 32) | zext lodivided byzext dinto the natural x86%edx:%eax / r32form, even with an explicitllvm.assume(hi < d)proving the quotient fits in 32 bits. - Current
llcemitsdivq.
Observed current-head code:
udiv_hi_lo:
movl %esi, %eax
shlq $32, %rdi
orq %rdi, %rax
movl %edx, %ecx
xorl %edx, %edx
divq %rcx
retqExpected x86_64 shape:
movl %edi, %edx
movl %esi, %eax
divl %ecx
retqSuggested bug report title:
llc x86_64 misses divl EDX:EAX idiom for (zext hi << 32 | zext lo) udiv zext d with assume(hi < d)