[llvm-bugs] [Bug 26597] New: [Greedy RegAlloc] register splitting around loop can reduce spills inside hot loop

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 12 13:42:53 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26597

            Bug ID: 26597
           Summary: [Greedy RegAlloc] register splitting around loop can
                    reduce spills inside hot loop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Register Allocator
          Assignee: unassignedbugs at nondot.org
          Reporter: wmi at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 15895
  --> https://llvm.org/bugs/attachment.cgi?id=15895&action=edit
testcase 1.cxx

For the testcase 1.cxx attached,
~/workarea/llvm-r255910/rbuild/bin/clang++ -O2 -S 1.cxx -o 1.s

.LBB1_2:                                # %while.body
                                        # =>This Inner Loop Header: Depth=1
        movq    %r13, %rdi
        callq   _Znam
        movq    %rax, %rbp
        movq    %r14, %rdi
        movq    %r15, %rsi
        movq    %rbp, %rdx
        callq   _Z4copyIPdS0_EvT_S1_T0_
        movq    8(%rsp), %rax           # 8-byte Reload
        leaq    (%rbp,%rax,8), %rsi
        movq    %rbp, %rdi
        callq   _Z6uniqueIPdEvT_S1_
        decl    %r12d
        cmpl    $1, %r12d
        jg      .LBB1_2

There is a spill reload inside the hot loop. However, callee save register %rbx
is never used inside the loop. It is used by a vreg which lives across the loop
without any reference inside of it. 

We can improve it by doing reg splitting for such vreg living across hot loop.
For the testcase above, the splitting will make %rbx available for the loop and
remove the spill from the loop. The code after reg splitting may look like the
following:

        movq    %rbx, 8(%rsp)         # Spill

.LBB1_2:                                # %while.body
                                        # =>This Inner Loop Header: Depth=1
        movq    %r13, %rdi
        callq   _Znam
        movq    %rax, %rbp
        movq    %r14, %rdi
        movq    %r15, %rsi
        movq    %rbp, %rdx
        callq   _Z4copyIPdS0_EvT_S1_T0_
        leaq    (%rbp,%rbx,8), %rsi
        movq    %rbp, %rdi
        callq   _Z6uniqueIPdEvT_S1_
        decl    %r12d
        cmpl    $1, %r12d
        jg      .LBB1_2

        movq    8(%rsp), %rbx          # Reload

-- 
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/20160212/f8a5ede8/attachment-0001.html>


More information about the llvm-bugs mailing list