[LLVMbugs] [Bug 2262] New: volatile load should not be moved inside loop

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Apr 29 08:26:53 PDT 2008


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

           Summary: volatile load should not be moved inside loop
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu


This is observed for recent SVN of llvm + gcc-4.2 on Ubuntu Feisty on x86-32.

This program:

volatile int g_1;

void loop (void)
{
  int b;
  for (b = 0; b < 10; b++)
    {
      g_1 += 5;
    }
}

int foo (void)
{
  loop ();
  return g_1;
}

compiled like this:

llvm-gcc -Os -S -Wall small.c

gives this output:

foo:
        pushl   %ebp
        movl    %esp, %ebp
        xorl    %ecx, %ecx
        movl    g_1, %eax
        .align  16
.LBB2_1:        # bb
        addl    $5, %eax
        movl    %eax, g_1
        incl    %ecx
        cmpl    $10, %ecx
        movl    g_1, %eax
        jne     .LBB2_1 # bb
.LBB2_2:        # bb9
        popl    %ebp
        ret

The final move of g_1 into eax should be outside of the loop.


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