[LLVMbugs] [Bug 9393] New: CodeGen keeps multiple copies of loop induction pointer

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 3 12:02:36 PST 2011


           Summary: CodeGen keeps multiple copies of loop induction
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: benny.kra at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=6271)
 --> (http://llvm.org/bugs/attachment.cgi?id=6271)

for this piece of C code:

int putchar(int);

void foo(unsigned u) {
  char buf[10];
  char *s = buf;

    *s++ = '0' + u % 10U;
  while (u /= 10U);
  while (--s >= buf)

clang -O2 generates:

_foo:                                   ## @foo
## BB#0:                                ## %entry
    pushl    %ebp
    movl    %esp, %ebp
    pushl    %ebx
    pushl    %edi
    pushl    %esi
    subl    $28, %esp
    leal    -23(%ebp), %ecx
    movl    8(%ebp), %esi
    movl    %ecx, -32(%ebp)         ## 4-byte Spill
    movl    %ecx, %edi
    movl    %ecx, %ebx
    .align    4, 0x90
LBB0_1:                                 ## %do.body
                                        ## =>This Inner Loop Header: Depth=1
    movl    %esi, %eax
    movl    $-858993459, %edx       ## imm = 0xFFFFFFFFCCCCCCCD
    mull    %edx
    shrl    $3, %edx
    imull    $10, %edx, %eax
    movl    %eax, -28(%ebp)         ## 4-byte Spill
    movl    %esi, %eax
    subl    -28(%ebp), %eax         ## 4-byte Folded Reload
    orl    $48, %eax
    movb    %al, 1(%ecx)
    incl    -32(%ebp)               ## 4-byte Folded Spill
    incl    %edi
    incl    %ebx
    incl    %ecx
    cmpl    $9, %esi
    movl    %edx, %esi
    ja    LBB0_1
## BB#2:                                ## %while.cond.preheader
    leal    -22(%ebp), %esi
    cmpl    %esi, -32(%ebp)         ## 4-byte Folded Reload
    jb    LBB0_4
    .align    4, 0x90
LBB0_3:                                 ## %while.body
                                        ## =>This Inner Loop Header: Depth=1
    movsbl    (%edi), %eax
    movl    %eax, (%esp)
    calll    _putchar
    decl    %edi
    decl    %ebx
    cmpl    %esi, %ebx
    jae    LBB0_3
LBB0_4:                                 ## %while.end
    addl    $28, %esp
    popl    %esi
    popl    %edi
    popl    %ebx
    popl    %ebp

Note the silly looking incl series in the first loop. This is a recent
regression, LLVM did produce better code a few months ago. The testcase is
reduced from FreeBSD's bootloader, which is very code size sensitive.

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