<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 --- - Trivial values not rematerialized"
href="https://llvm.org/bugs/show_bug.cgi?id=23289">23289</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Trivial values not rematerialized
</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>Windows NT
</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>Register Allocator
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>james.molloy@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code produces really suboptimal code seemingly on all targets.
#define N 16
extern void g(int);
int f(int *p, int n) {
for (int i = 0; i < n; ++i) {
for (int k = 0; k < n; ++k) {
#pragma clang loop unroll(full)
for (int j = 0; j < N; ++j)
g((j+i)*k);
}
}
}
It produces a bunch of spills: (main loop block):
.LBB0_2: @ %.preheader.lr.ph.us
[31/1853]
@ =>This Loop Header: Depth=1
@ Child Loop BB0_3 Depth 2
mov r5, r4
mov r9, #0
add r0, r5, #11
add r6, r5, #4
add r7, r5, #3
add r8, r5, #2
add r4, r5, #1
str r0, [sp, #24] @ 4-byte Spill
add r0, r5, #10
str r0, [sp, #20] @ 4-byte Spill
add r0, r5, #9
str r0, [sp, #16] @ 4-byte Spill
add r0, r5, #8
str r0, [sp, #12] @ 4-byte Spill
add r0, r5, #7
str r0, [sp, #8] @ 4-byte Spill
add r0, r5, #6
str r0, [sp, #4] @ 4-byte Spill
add r0, r5, #5
str r0, [sp] @ 4-byte Spill
.LBB0_3: @ %.preheader.us
@ Parent Loop BB0_2 Depth=1
@ => This Inner Loop Header: Depth=2
mul r0, r5, r9
bl g
mul r0, r4, r9
bl g
mul r0, r8, r9
bl g
mul r0, r7, r9
bl g
mul r0, r6, r9
bl g
ldr r0, [sp] @ 4-byte Reload
mul r0, r0, r9
bl g
ldr r0, [sp, #4] @ 4-byte Reload
mul r0, r0, r9
bl g
ldr r0, [sp, #8] @ 4-byte Reload
... snip, more like this ...
X86 also shows massive spilling. The instructions outside the loop are
trivially rematerializable, but for some reason seem not to be considered.
Because this affects all targets, I suspect this is a bug in the core RA/Spill
placement algorithm.</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>