<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] failed to canonicalize bitwise logic to icmps"
href="https://bugs.llvm.org/show_bug.cgi?id=32401">32401</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstCombine] failed to canonicalize bitwise logic to icmps
</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>In D31290 (<a href="https://reviews.llvm.org/D31290">https://reviews.llvm.org/D31290</a>), I had a hard time getting llvm to
produce the optimal scalar code that Eli suggested.
The type is 'char' here, but that doesn't matter for the purpose of this bug.
char cmpeq_bitwise(char x0, char y0, char x1, char y1) {
return ((x0 ^ y0) | (x1 ^ y1)) == 0;
}
char cmpeq_logical(char x0, char y0, char x1, char y1) {
return ((x0 ^ y0) || (x1 ^ y1)) == 0;
}
Before we get to the codegen, we have a missing IR canonicalization of these
equivalent functions:
define i8 @cmpeq_bitwise(i8 %a, i8 %b, i8 %c, i8 %d) {
%xor1 = xor i8 %a, %b
%xor2 = xor i8 %c, %d
%or = or i8 %xor1, %xor2
%cmp = icmp eq i8 %or, 0
%z = zext i1 %cmp to i8
ret i8 %z
}
define i8 @cmpeq_logical(i8 %a, i8 %b, i8 %c, i8 %d) {
%cmp1 = icmp eq i8 %a, %b
%cmp2 = icmp eq i8 %c, %d
%and = and i1 %cmp1, %cmp2
%z = zext i1 %and to i8
ret i8 %z
}
<a href="http://rise4fun.com/Alive/C6n">http://rise4fun.com/Alive/C6n</a>
We should prefer the 2nd form because it has less instructions? FWIW, x86
codegen looks better for the 1st form, so we may need to reverse the transform
in the backend.</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>