[LLVMbugs] [Bug 23289] New: Trivial values not rematerialized
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Apr 19 10:26:39 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23289
Bug ID: 23289
Summary: Trivial values not rematerialized
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Register Allocator
Assignee: unassignedbugs at nondot.org
Reporter: james.molloy at arm.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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.
--
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/20150419/e8f17efb/attachment.html>
More information about the llvm-bugs
mailing list