[LLVMbugs] [Bug 3230] New: sched creates crazy register pressure + spilling

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 17 13:09:02 PST 2008


http://llvm.org/bugs/show_bug.cgi?id=3230

           Summary: sched creates crazy register pressure + spilling
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality
          Severity: normal
          Priority: P2
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: gohman at apple.com, llvmbugs at cs.uiuc.edu


Consider:
---
int test2(void);
#define my_copy(x) tmp = test2(); err |= tmp
int test(void){
        int err = 0, tmp;
        my_copy( 0); my_copy( 1); my_copy( 2); my_copy( 3);
        my_copy( 4); my_copy( 5); my_copy( 6); my_copy( 7);
        my_copy( 8); my_copy( 9); my_copy(10); my_copy(11);
        my_copy(12); my_copy(13); my_copy(14); my_copy(15);
        my_copy(16); my_copy(17); my_copy(18); my_copy(19);
        my_copy(20); my_copy(21); my_copy(22); my_copy(23);
        my_copy(24); my_copy(25); my_copy(26); my_copy(27);
        my_copy(28); my_copy(29); my_copy(30); my_copy(31);
        return err;
}
---

we currently compile it to:

        call    L_test2$stub
        movl    %eax, -96(%ebp)
        call    L_test2$stub
        movl    %eax, -100(%ebp)
        call    L_test2$stub
        movl    %eax, -104(%ebp)
        call    L_test2$stub
        movl    %eax, -108(%ebp)
...
        orl     -32(%ebp), %esi
        orl     -36(%ebp), %esi
        orl     -40(%ebp), %esi
        orl     -44(%ebp), %esi
...

If each or is scheduled immediately after its call, we'd get much better code
and no spilling at all.  GCC 4.0 (but not 4.2) produces:

...
        call    L_test2$stub
        orl     %eax, %esi
        call    L_test2$stub
        orl     %eax, %esi
        call    L_test2$stub
        orl     %eax, %esi
        call    L_test2$stub
        orl     %eax, %esi
...

Which is much nicer.  We actually get this code with:

$ llvm-gcc t.c -S -o - -O0 -emit-llvm | llvm-as | opt -mem2reg | llc -fast

Because -fast doesn't mess around with the schedule.  If you turn on the dag
scheduler, it will "break" the code.

This is derived from GCC PR 38533.

-Chris


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list