<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 --- - [GC] Effective rematerialization at non-entry polls"
href="https://llvm.org/bugs/show_bug.cgi?id=26223">26223</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[GC] Effective rematerialization at non-entry polls
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>listmail@philipreames.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>(This bug is specific to the implementation of rewrite-statepoints-for-gc.)
If we have a bit of code like this:
%addr = gep %o, 8
loop {
if (poll) {
safepoint();
}
load %addr
}
We currently end up rewriting this as:
%addr = gep %o, 8
loop {
%addr1 = phi (%addr, %addr2)
if (poll) {
safepoint();
%remat = gep %o.relocated, 8
}
%addr2 = phi (%addr1, %remat)
load %addr2
}
This ends up forcing us to rematerialize the address explicitly and likely will
cause us to spill/fill the address if register constrained. This creates a
bunch of dependent loads (fill from stack, load from result) which show up as
hot in a couple of benchmarks.
A much better result would be:
%addr = gep %o, 8
loop {
if (poll) {
safepoint();
}
%remat = gep %o.relocated, 8
load %remat
}
This version allows the GEP to be folded directly into x86's native addressing
modes.
(Note: For conciseness, I'm not writing the phis for relocating %o, assume
they're all there.)
I can see a couple of ways of approaching this:
- Rematerialize not at relocations, but at uses. This would require either a
post rewriting CSE to clean up, or a bit of smarts to avoid naive placement.
This might be overly x86 specific.
- Push rematerializations into unconditional successors. This would have the
effect of eliminating PHIs (because we know the remat is also legal there).
- Add a post processing pass which tries to pull remat values through their
only use. This could be done as either a step in RS4GC, or possibly just an
instcombine rule. Given a single use gep of a gc-relocate, look to see if the
single use is a phi of the original value. If so, replace the PHI with a gep
of the PHI producing the fixed up base.</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>