<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 --- - [ppc] Store forwarding caused by use after copy"
href="https://llvm.org/bugs/show_bug.cgi?id=30606">30606</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ppc] Store forwarding caused by use after copy
</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: 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>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Compile following source code with options
-m64 -O2 -mvsx -mcpu=power8
struct S {
char* p1;
char* p2;
char* p3;
char* p4;
};
void bar(struct S*);
void foo(struct S *p) {
struct S s = *p;
if (s.p1 > s.p2)
return;
bar(&s);
}
LLVM generates:
foo: # @foo
.Lfunc_begin0:
.Lfunc_gep0:
addis 2, 12, .TOC.-.Lfunc_gep0@ha
addi 2, 2, .TOC.-.Lfunc_gep0@l
.Lfunc_lep0:
.localentry foo, .Lfunc_lep0-.Lfunc_gep0
# BB#0: # %entry
mflr 0
std 31, -8(1)
std 0, 16(1)
stdu 1, -144(1)
li 4, 16
mr 31, 1
lxvd2x 0, 3, 4 // copy
addi 5, 31, 96
stxvd2x 0, 5, 4 // copy
ori 2, 2, 0
lxvd2x 0, 0, 3 // copy
stxvd2x 0, 0, 5 // copy
ori 2, 2, 0
ld 3, 96(31) // load again
ld 12, 104(31) // load again
cmpld 3, 12
bgt 0, .LBB0_2
# BB#1: # %if.end
addi 3, 31, 96
bl bar
nop
.LBB0_2: # %cleanup
addi 1, 1, 144
ld 0, 16(1)
ld 31, -8(1)
mtlr 0
blr
First it uses lxvd2x/stxvd2x instructions to copy *p to s, after that it loads
s.p1 and s.p2 immediately, it triggers the slow store forwarding.
A faster code should load p->p1 and p->p2 instead. Or copy through general
registers, then reuse those values.
A minor problem is the scheduling of lxvd2x/stxvd2x instructions.</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>