[LLVMbugs] [Bug 1435] NEW: licm ignores volatile store

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu May 17 15:47:43 PDT 2007


           Summary: licm ignores volatile store
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: zhiruz at gmail.com

I know that there is some recent discussions about the optimizations on 
volatile loads and stores, and the conclusion is that LLVM is doing the right 
thing. But this time the story seems different. 

See below for details. The test case will be posted shortly. 

For my first example, LLVM is able to preserve both volatile load and store 

void PassThrough(volatile int* DataIn, volatile int* DataOut)
  int i;
  int buffer[64];

  for (i = 0; i < 64; i++)
    buffer[i] = *DataIn;

  for (i = 0; i < 64; i++)
    *DataOut = buffer[i];

For the second one, however, LICM will move the volatile store outside of the 
loop, which is apparently wrong. 

void Transpose(volatile int* DataIn, volatile int* DataOut)
  int i, j;
  int buffer[64];

  for (i = 0; i < 64; i++)
    buffer[i] = *DataIn;

  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++)
      *DataOut = buffer[j * 8 + i];

What I did:

llvm-gcc -O0 -c -emit-llvm test_volatile.c -o test.bc
opt -mem2reg -licm test.bc -o new.bc -f

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list