<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 - [Regression] sub nsw i32 %x, -1 gets transformed into add i32 %0, 2147483647 illegally"
href="https://bugs.llvm.org/show_bug.cgi?id=36304">36304</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Regression] sub nsw i32 %x, -1 gets transformed into add i32 %0, 2147483647 illegally
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arphaman@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>LLVM transforms the 'sub nsw i32 %x, -1' instruction into 'add i32 %0,
2147483647' illegally.
Reproducer:
$ cat test.cpp
typedef unsigned long size_t;
void *memcpy(void *__dst, const void *__src, size_t __n);
int Execute(int &minSize, char *Output, const char *Input) {
for (int d=0; d<64; ++d) {
for (int s=0; s<64; ++s) {
for (int n=0; n<3; ++n) {
size_t len = minSize + (n*0x11389737 & minSize-1);
memcpy(Output+d, Input+s, len);
}
}
}
return 0;
}
$ ~/u/b/bin/clang repr.cpp -S -Xclang -emit-llvm -O1 -o ir.ll
$ cat ir.ll
Bad pass: "Combine redundant instructions"
...
%mul = mul nuw nsw i32 %n.028, 288921399
%sub = add i32 %0, 2147483647
%and = and i32 %sub, %mul
...</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>