[llvm-bugs] [Bug 43159] New: Bug in TargetLowering::SimplifyDemandedBits causing miscompile
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 29 00:13:57 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43159
Bug ID: 43159
Summary: Bug in TargetLowering::SimplifyDemandedBits causing
miscompile
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: warren_ristow at playstation.sony.com
CC: llvm-bugs at lists.llvm.org
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
---
> id10564:33bf530 a4ee4a 29726e7 21dfb3
$
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190829/3c00fa83/attachment.html>
More information about the llvm-bugs
mailing list