[LLVMdev] Spills and values present in both registers & stack
David Blaikie
dblaikie at gmail.com
Thu Jul 28 16:05:49 PDT 2011
On Tue, Jul 26, 2011 at 11:35 AM, Taral <taralx at gmail.com> wrote:
>
> One piece of code I'm writing has a lot of intermediates, and I'm
> trying to optimize down the number of memory accesses. Here's a
> snippet from the start of the function, where I think there is some
> low-hanging fruit:
>
> # BB#0:
> pushq %rbp
> pushq %r15
> pushq %r14
> pushq %r13
> pushq %r12
> pushq %rbx
> movq %rdx, %rcx
> movq %rdi, -16(%rsp) # 8-byte Spill
> movq (%rsi), %rdi
> movq 8(%rsi), %r8
> movq 8(%rcx), %rax
> movq %rax, -24(%rsp) # 8-byte Spill
> movq 16(%rcx), %rax
> movq %rax, -8(%rsp) # 8-byte Spill
> movq %rdi, %rax
> mulq -24(%rsp) # 8-byte Folded Reload
>
> You'll note that rbx,r12,r13,r14,r15,rbp are all dead after the
> pushes. But the spill code still insists on using rax to load the
> spilled values, forcing them to be reloaded later.
I'm not the most familiar with this sort of thing - but a small
example (of llvm bitcode) & the optimization flags you used, etc,
might be helpful (& I might be able to have a go at explaining it, if
no one else does).
> Is the register
> allocator (pbqp, I think) capable of having values in registers and on
> the stack at the same time?
I can at least confirm that the default register allocator on x86
isn't PBQP, it's the greedy allocator (unless your'e compiling with
-O0, in which case it's the fast allocator).
- David
More information about the llvm-dev
mailing list