[llvm-bugs] [Bug 32320] New: [ppc] crandc of two cmps is much slower than two cmp/br
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 16 16:58:05 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32320
Bug ID: 32320
Summary: [ppc] crandc of two cmps is much slower than two
cmp/br
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: PowerPC
Assignee: unassignedbugs at nondot.org
Reporter: carrot at google.com
CC: llvm-bugs at lists.llvm.org
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170316/16796e0c/attachment.html>
More information about the llvm-bugs
mailing list