<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 - [ppc] crandc of two cmps is much slower than two cmp/br"
href="https://bugs.llvm.org/show_bug.cgi?id=32320">32320</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ppc] crandc of two cmps is much slower than two cmp/br
</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>Backend: PowerPC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>carrot@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Compile following source code with options -mvsx -mcpu=power8 -O2
struct S{
struct S* next;
};
struct S* foo(struct S* p, struct S* e)
{
struct S* n;
for (; (n = p->next) !=0 && n < e; p = n);
return n;
}
LLVM generates:
foo: # @foo
.Lfunc_begin0:
# BB#0: # %entry
.p2align 5
.LBB0_1: # %for.cond
# =>This Inner Loop Header: Depth=1
ld 3, 0(3)
cmpdi 3, 0 // (n = p->next) !=0
cmpld 1, 3, 4 // n < e
crandc 20, 4, 2 // &&
bc 12, 20, .LBB0_1
# BB#2: # %for.end
blr
It uses crandc to combine the previous two cmp results, and then branch. It is
much slower than 2 simple cmp/br on power8, because crandc has data dependence
on previous cmp instructions, they have 5 cycles latency. In an internal
bigtable benchmark, the crandc version has only half of the performance of the
simple cmp/br version, with a similar code pattern.</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>