<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Clang miscompilation due to loop vectorization"
href="http://llvm.org/bugs/show_bug.cgi?id=20421">20421</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang miscompilation due to loop vectorization
</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>Linux
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>vonosmas@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, nlewycky@google.com, qcolombet@apple.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Reproduces on x86_64 Linux with ToT Clang. I've ran a bisect and it pointed
to LLVM r212808, so this might be a recent bug.
$ cat tmp/optbug/a.cc
#include <stdio.h>
const int NUM = 28;
const int SCALE = 12;
const int ERROR_IDX = 24;
void ScaleArray2(int *a, int *h, int m) {
for (int i = 0; i < NUM; ++i) {
int original_delta = h[i];
int scaled_delta = (original_delta * m) / SCALE;
a[i] -= original_delta;
a[i] += scaled_delta;
}
}
int main() {
int a[] = {-1662, 1623, -882, 2348, 1639, 1957, 1480, 1866, 1835, 1529,
1710, 1805, 1620, 1571, 1882, 1601, 1603, 1669, 1333, 2172,
1745, -1800, 1555, 1752, 1462, -654, 1522, 1744};
int h[] = {138, 0, 300, 280, 0, 174, 0, 0, 103, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 220, 0, 0, 0, 0, -60, 0, 0, 0};
printf("%d - %d + 4/12*%d = ", a[ERROR_IDX], h[ERROR_IDX], h[ERROR_IDX]);
ScaleArray2(a, h, 4);
printf("%d\n", a[ERROR_IDX]);
};
$ ./bin/clang++ -O2 tmp/optbug/a.cc && ./a.out
1462 - -60 + 4/12*-60 = 357915443</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>