Skip to content

[LoopInterchange] Loops should not interchanged due to control flow #47401

@llvmbot

Description

@llvmbot
Bugzilla Link 48057
Version trunk
OS Linux
Attachments Added the corresponding IR file
Reporter LLVM Bugzilla Contributor

Extended Description

$ clang -mllvm -enable-loopinterchange=true -O2 reproducer.c -w && ./a.out
0
$ clang -mllvm -enable-loopinterchange=false -O2 reproducer.c -w && ./a.out
5
$ clang -O0 reproducer.c -w && ./a.out
5

reproducer.c:

#include <stdio.h>
char b[][8] = {{}, {}, {}, {}, {5}, {}, 2, 3};
int c, d;
short e;
static char f() {
for (; c <= 7; c++) {
d = 4;
for (; d; d--)
b[d + 2][c] && (e = b[d][0]);
}
}
int main() {
f();
printf("%d\n", e);
}

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