<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - We should generate the xor idiom instead of movzbl for zext even if not directly fed by setcc."
href="https://llvm.org/bugs/show_bug.cgi?id=28442">28442</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>We should generate the xor idiom instead of movzbl for zext even if not directly fed by setcc.
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mkuper@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Consider:
int foo(int a, int b, int c) {
return (a > 0 && b > 0 && c > 0);
}
Right now, we generate:
testl %edi, %edi
setg %al
testl %esi, %esi
setg %cl
andb %al, %cl
testl %edx, %edx
setg %al
andb %cl, %al
movzbl %al, %eax
retq
This does not get caught by r274692, because the setcc doesn't feed directly
into the zext. This is true starting from the IR level:
%cmp = icmp sgt i32 %a, 0
%cmp1 = icmp sgt i32 %b, 0
%or.cond = and i1 %cmp, %cmp1
%cmp2 = icmp sgt i32 %c, 0
%cmp2. = and i1 %or.cond, %cmp2
%land.ext = zext i1 %cmp2. to i32
ret i32 %land.ext
The performance impact is the same as in the usual "setcc + zext" cases:
int main() {
unsigned x = 0;
unsigned y = 0;
for (unsigned i = 0; i < 2000; ++i) {
for (unsigned j = 0; j < 2000; ++j) {
for (unsigned k = 0; k < 2000; ++k) {
y += ((i >= 10) && (j >= 20) && (k >= 30));
}
}
}
return y;
}
When compiled with clang -O2 -fno-vectorize -fno-unroll-loops runs for 7.8s on
my machine. Using the xor idiom, it runs for 4.9s.</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>