<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 - [InstCombine] Missed @llvm.usub.sat opportunity"
href="https://bugs.llvm.org/show_bug.cgi?id=45160">45160</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstCombine] Missed @llvm.usub.sat opportunity
</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>Linux
</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>lebedev.ri@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Given <a href="https://godbolt.org/z/gGcybp">https://godbolt.org/z/gGcybp</a>
using size_type = unsigned;
size_type t0(size_type pos, size_type size) {
size_type bytesRemaining = (pos < size) ? size - pos : 0;
return ((bytesRemaining > 4)
? (size - pos - 4)
: 0);
}
we currently produce
define dso_local i32 @_Z2t0jj(i32 %0, i32 %1) local_unnamed_addr #0 {
%3 = tail call i32 @llvm.usub.sat.i32(i32 %1, i32 %0)
%4 = icmp ugt i32 %3, 4
%5 = sub i32 -4, %0
%6 = add i32 %5, %1
%7 = select i1 %4, i32 %6, i32 0
ret i32 %7
}
declare i32 @llvm.usub.sat.i32(i32, i32) #1
but we should instead produce
define dso_local i32 @_Z6squarejj(i32 %0, i32 %1) local_unnamed_addr #0 {
%3 = tail call i32 @llvm.usub.sat.i32(i32 %1, i32 %0)
%4 = tail call i32 @llvm.usub.sat.i32(i32 %3, i32 4)
ret i32 %4
}
declare i32 @llvm.usub.sat.i32(i32, i32) #1
----------------------------------------
define i8 @_Z6squarejj(i8 %0, i8 %1) {
%2:
%3 = usub_sat i8 %1, %0
%4 = icmp ugt i8 %3, 4
%5 = sub i8 252, %0
%6 = add i8 %5, %1
%7 = select i1 %4, i8 %6, i8 0
ret i8 %7
}
=>
define i8 @_Z6squarejj(i8 %0, i8 %1) {
%2:
%3 = usub_sat i8 %1, %0
%4 = usub_sat i8 %3, 4
ret i8 %4
}
Transformation seems to be correct!
Summary:
1 correct transformations
0 incorrect transformations
0 Alive2 errors</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>