<html>
<head>
<base href="https://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 --- - NewGVN miscompile"
href="https://llvm.org/bugs/show_bug.cgi?id=31554">31554</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>NewGVN miscompile
</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>greg_bedwell@sn.scee.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Blocks</th>
<td>30995
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Found a bad runtime result with -enable-newgvn on one of our test suites. I'm
currently out of the office until mid-next-week so haven't had a chance to look
in-depth at the codegen to see if it's a duplicate of an existing report
against NewGVN, but I figured it would be better to raise it now than in a
week's time as I have a nice self-contained test-case already.
$./build/bin/clang --version
clang version 4.0.0 (trunk 291148)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/greg/public_git/./build/bin
$./build/bin/clang -O2 1.cpp -o 1.elf && ./1.elf
loop A: CC[0] <- AA[0] (10)
loop B: CC[1] <- BB[0] (20)
loop B: CC[2] <- BB[1] (21)
loop B: CC[3] <- BB[2] (22)
loop B: CC[4] <- BB[3] (23)
loop B: CC[5] <- BB[4] (24)
loop B: CC[6] <- BB[5] (25)
loop B: CC[7] <- BB[6] (26)
10, 20, 21, 22, 23, 24, 25, 26
$./build/bin/clang -O2 -mllvm -enable-newgvn 1.cpp -o 1.elf && ./1.elf
loop A: CC[0] <- AA[0] (10)
loop B: CC[1] <- BB[0] (20)
loop B: CC[2] <- BB[1] (21)
loop B: CC[3] <- BB[2] (22)
loop B: CC[4] <- BB[3] (23)
loop B: CC[5] <- BB[4] (24)
loop B: CC[6] <- BB[5] (25)
loop B: CC[7] <- BB[6] (26)
0, 20, 21, 22, 23, 24, 25, 26
^~~~~ should be 10
// ============================================================================
extern "C" int printf(const char *, ...);
typedef char __attribute__((vector_size(8))) vec8;
vec8 foo(unsigned mask) {
vec8 AA = (vec8){10, 11, 12, 13, 14, 15, 16, 17};
vec8 BB = (vec8){20, 21, 22, 23, 24, 25, 26, 27};
vec8 CC;
if (mask == 0)
return BB;
int idxA = 0;
for (; idxA < mask; ++idxA, --mask) {
int a = idxA;
int b = mask - 1;
int c = AA[b];
printf("loop A: CC[%d] <- AA[%d] (%d)\n", a, b, c);
CC[a] = c;
}
for (int idxB = 0; idxA < 8; ++idxA, ++idxB) {
int a = idxA;
int b = idxB;
int c = BB[b];
printf("loop B: CC[%d] <- BB[%d] (%d)\n", a, b, c);
CC[a] = c;
}
return CC;
}
int main() {
vec8 r = foo(1);
printf("%d, %d, %d, %d, %d, %d, %d, %d\n", r[0], r[1], r[2], r[3], r[4],
r[5],
r[6], r[7]);
}
// ============================================================================</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>