<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Re-evaluate loop unrolling for size"
href="https://bugs.llvm.org/show_bug.cgi?id=33128">33128</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Re-evaluate loop unrolling for size
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>davide@freebsd.org
</td>
</tr>
<tr>
<th>CC</th>
<td>davidxl@google.com, eraman@google.com, filcab@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, simon.f.whittaker@gmail.com, tejohnson@google.com, xinliangli@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Currently, LLVM doesn't run `-loop-unroll` *at all* at -Os.
GCC, OTOH, does it, and this allows them to reduce the size of the generated
code, e.g. when unrolling loops with small (constant) trip counts:
<a href="https://godbolt.org/g/PpF4DG">https://godbolt.org/g/PpF4DG</a>
extern int f(int);
int tinkywinky(void) {
int x;
for (int i = 0; i < 2; ++i) {
x += f(i);
}
return x;
}
[davide@cupiditate unroll]$ gcc -Os unroll.c -c -o unroll-gcc.o
[davide@cupiditate unroll]$ ../clang -Os unroll.c -c -o unroll-clang.o
[davide@cupiditate unroll]$ size unroll-gcc.o
text data bss dec hex filename
80 0 0 80 50 unroll-gcc.o
[davide@cupiditate unroll]$ size unroll-clang.o
text data bss dec hex filename
86 0 0 86 56 unroll-clang.o
We could also consider having this driven by profile informations to unroll
regions that are hot (and never touch regions that are cold). This has to make
conservative decisions as loop unrolling is an optimization that generally
increases the size of the final executable.
CC:ing some GCC/PGO experts for thoughts.</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>