[LLVMdev] Spills and values present in both registers & stack

Taral taralx at gmail.com
Tue Jul 26 11:35:16 PDT 2011


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. Is the register
allocator (pbqp, I think) capable of having values in registers and on
the stack at the same time?

-- 
Taral <taralx at gmail.com>
"Please let me know if there's any further trouble I can give you."
    -- Unknown




More information about the llvm-dev mailing list