| | | | --- | --- | | Bugzilla Link | [47523](https://llvm.org/bz47523) | | Version | trunk | | OS | Linux | | Attachments | [reproducer](https://user-images.githubusercontent.com/9026344/143761203-ee19237e-932c-4efb-8db7-ff066c0861f9.gz), [reproducer.ll](https://user-images.githubusercontent.com/9026344/143761204-261cf990-493f-447a-9c80-de9837c6324a.gz) | | CC | @fhahn | ## Extended Description $ clang -mllvm -enable-loopinterchange -O2 reproducer.c -w && ./a.out 11 $ clang -O0 reproducer.c -w && ./a.out 9 LoopInterchange wrongly interchanges loops in the following function "h()", in which the order of *s=3 matters: struct a { unsigned char b } c[]; d, e, g; f[4][9] = {5, 3}; h() { for (; d <= 2; d++) { for (e = 0; e <= 2; e++) { short *s = &g; if ((long)(f[e][d] && (*s = 3), c) % 4073709551606) ++*s; } } } main() { h(); printf("%d\n", g); }