<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [LoopInterchange] Interchange breaks program correctness"
href="https://bugs.llvm.org/show_bug.cgi?id=47523">47523</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[LoopInterchange] Interchange breaks program correctness
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chenmindong120@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23956" name="attach_23956" title="reproducer">attachment 23956</a> <a href="attachment.cgi?id=23956&action=edit" title="reproducer">[details]</a></span>
reproducer
$ 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);
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>