-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
licm breaks volatile store in multiply-nested loops #1807
Labels
Comments
assigned to @lattner |
This sounds like a real bug. |
Nice catch. This impacts nested loops only. Thanks for the excellent testcase reduction. Fixed. Testcase here: Transforms/LICM/2007-05-22-VolatileSink.ll Patch here: -Chris |
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
kitano-metro
pushed a commit
to RIKEN-RCCS/llvm-project
that referenced
this issue
Mar 7, 2023
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extended Description
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
correctly.
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
The text was updated successfully, but these errors were encountered: