Skip to content

[LoopInterchange] Loops should not interchanged due to dependencies #47259

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 47915
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @DMG862

Extended Description

$ clang -mllvm -enable-loopinterchange -O2 reproducer.c -w && ./a.out
4096
0
4096
0

$ clang -O0 reproducer.c -w && ./a.out
4096
4096
4096
4096

reproducer.c:

#include <stdio.h>
int a;
int c[4][4];
*f = &a;

void test_deps() {
for (int i = 0; i <= 3; i++) {
for (int j = 0; j <= 3; j++) {
*f ^= 0x1000;
c[j][i] = *f;
}
}
}

main() {
test_deps();
for (int k = 0; k < 4; k++)
printf("%d\n", c[0][k]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions