<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 - Bug in TargetLowering::SimplifyDemandedBits causing miscompile"
href="https://bugs.llvm.org/show_bug.cgi?id=43159">43159</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Bug in TargetLowering::SimplifyDemandedBits causing 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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>warren_ristow@playstation.sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>One of our random test-generators found a miscompile bug. Bisecting identifies
that the problem first appeared at r357992. (Also verified that the problem
still appears with a fairly modern version -- checked r370150.)
Below is a reduced source-level repro.
$ cat test.cpp
// ==========================================================================
extern "C" int printf(const char *, ...);
typedef unsigned char uchar;
typedef unsigned int uint;
typedef uint __attribute__((ext_vector_type(4))) uint4;
typedef uchar __attribute__((ext_vector_type(4))) uchar4;
typedef union { uint4 a; uint4 b; } union_uint4_uint4;
int main() {
union_uint4_uint4 id10565;
id10565.a = (uint4) {
(uint)319633044, (uint)1642820125, (uint)1902706568, (uint)38856794
};
static volatile uint4 id10567 = (uint4) {
(uint)-836963667, (uint)-1733256558, (uint)-1778869956, (uint)392932137
};
uchar4 id10569 = (uchar4) {
(uchar)328580007, (uchar)-1839000083, (uchar)228515326, (uchar)1143154097
};
uint4 id10568 = __builtin_convertvector(id10569, uint4);
uint4 id10566 = id10567 / id10568;
uint4 id10564 = (((id10565.b = id10566), id10565.a));
printf("id10564:%x %x %x %x\n",
id10564[0], id10564[1], id10564[2], id10564[3]);
return 0;
}
// ==========================================================================
$
$ # With llvm 8.0, the results are the same at -O0 and -O1:
$ ~/llvm.8.0/bin/clang++ -O0 -o test.elf test.cpp
$ test.elf | tee llvm8.txt
id10564:13bf530 a4ee4a 9726e7 21dfb3
$ ~/llvm.8.0/bin/clang++ -O1 -o test.elf test.cpp
$ test.elf | diff llvm8.txt -
$
$ # At r357992, the optimized results differ from the unoptimized results:
$ r357992/bin/clang++ --version | egrep 'version'\|'Target'
clang version 9.0.0 (trunk 357992)
Target: x86_64-unknown-linux-gnu
$ r357992/bin/clang++ -O0 -o test.elf test.cpp
$ test.elf | diff llvm8.txt -
$ r357992/bin/clang++ -O1 -o test.elf test.cpp
$ test.elf | diff llvm8.txt -
1c1
< id10564:13bf530 a4ee4a 9726e7 21dfb3
---
<span class="quote">> id10564:33bf530 a4ee4a 29726e7 21dfb3</span >
$</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>