<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 - [InstSimplify] fold compare of no-wrap subtract"
href="https://bugs.llvm.org/show_bug.cgi?id=52135">52135</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstSimplify] fold compare of no-wrap subtract
</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>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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Noticed in <a href="https://reviews.llvm.org/rGda210f5d3425">https://reviews.llvm.org/rGda210f5d3425</a> :
define i1 @test_negative_combined_sub_signed_overflow(i8 %x) {
%y = sub nsw i8 127, %x
%z = icmp slt i8 %y, -1
ret i1 %z
}
This is always false.
define i1 @test_negative_combined_sub_unsigned_overflow(i64 %x) {
%y = sub nuw i64 10, %x
%z = icmp ult i64 %y, 11
ret i1 %z
}
This is always true.
--------------------------------------------------------------------------
-instcombine will now handle those transforms in multiple steps, but it won't
work if the subtract has an extra use.
This should be added to -instsimplify, so we don't have that limitation, and
the analysis can be used by other passes.
The transforms should not be limited to "less-than" predicates. The check might
be implemented with a ConstantRange or an overflow check on constant math.</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>