[LLVMbugs] [Bug 3496] New: LLVM misses some loop optimizations compared to GCC

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Feb 6 00:42:58 PST 2009


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

           Summary: LLVM misses some loop optimizations compared to GCC
           Product: libraries
           Version: trunk
          Platform: All
               URL: http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-
                    February/019976.html
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: romixlev at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


Moving of sub-expressions from loops and replacement of array
accesses via pointer-based induction variables is not optimal in
some situations.

Here is the code genereated by LLVM:
.LBB2_2:        # bb31
        movl    12(%esp), %ecx
        movl    8(%esp), %eax
        cmpl    $0, up+28(%eax,%ecx,4)
        je      .LBB2_9 # bb569
.LBB2_3:        # bb41         ; <--- bb31 is the only predecessor of bb41
        movl    12(%esp), %ecx 
        movl    4(%esp), %eax
        cmpl    $0, down(%eax,%ecx,4)
        je      .LBB2_9 # bb569



   In the example mentioned above, both blocks are executed inside a
loop enclosing them. And they keep evaluating  e.g. the
down(%eax,%ecx,4) expression on every iteration. 

GCC at the same time hoists this expression outside of the loop and replaces it
with a simple pointer, as you can see below:

.LBB2_2:
        movl    -32(%ebp), %edx
        movl    28(%edx), %eax
        testl   %eax, %eax
        je      .L5

.LBB2_3:
        movl    -48(%ebp), %eax
        movl    (%eax), %edi
        testl   %edi, %edi
        je      .L5


For more information and test-case files please see this mail-thread:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-February/019976.html


-- 
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