<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 - [ValueTracking] recognize 'not' variant of min-of-min"
href="https://bugs.llvm.org/show_bug.cgi?id=35834">35834</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ValueTracking] recognize 'not' variant of min-of-min
</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>Forking this off from <a class="bz_bug_link
bz_status_NEW "
title="NEW - Regression for three way min/max"
href="show_bug.cgi?id=35717">bug 35717</a>:
We have a pixel component min/max pattern in C as:
for (int i = 0; i < I; i++) {
xc = *A++;
xm = *A++;
xy = *A++;
xc = 255-xc;
xm = 255-xm;
xy = 255-xy;
if (xc < xm)
xk = xc < xy ? xc : xy;
else
xk = xm < xy ? xm : xy;
*B++ = xk;
}
----------------------------------------------------------------------------
Which currently optimizes to this IR:
define i8 @test(i8 %xc, i8 %xm, i8 %xy) {
%c0 = xor i8 %xc, -1
%m1 = xor i8 %xm, -1
%y2 = xor i8 %xy, -1
%cmp = icmp ult i8 %xm, %xc
%cmp13 = icmp ult i8 %c0, %y2
%cond = select i1 %cmp13, i8 %c0, i8 %y2
%cmp20 = icmp ult i8 %m1, %y2
%cond27 = select i1 %cmp20, i8 %m1, i8 %y2
%xk.0.in = select i1 %cmp, i8 %cond, i8 %cond27
ret i8 %xk.0.in
}
----------------------------------------------------------------------------
The 'not' of the compared ops is preventing recognition (and potential
simplification via <a href="https://reviews.llvm.org/D41603">https://reviews.llvm.org/D41603</a> ) of this chain of min/max.
We matched the simpler sequence with:
<a href="https://reviews.llvm.org/rL321672">https://reviews.llvm.org/rL321672</a></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>