<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 - Missed loop unrolling opportunity"
href="https://bugs.llvm.org/show_bug.cgi?id=52354">52354</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed loop unrolling opportunity
</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>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>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>#define C 3
struct node {
struct node *next;
int payload;
};
static int count_nodes(const node* p) {
int size = 0;
while (p) {
p = p->next;
size++;
}
return size;
}
bool has_one_node(const node* p) {
return count_nodes(p) == 1;
}
bool has_C_nodes(const node* p) {
return count_nodes(p) == C;
}
has_one_node(node const*): # @has_one_node(node const*)
test rdi, rdi
je .LBB0_1
mov eax, 1
.LBB0_3: # =>This Inner Loop Header: Depth=1
mov rdi, qword ptr [rdi]
add eax, -1
test rdi, rdi
jne .LBB0_3
test eax, eax
sete al
ret
.LBB0_1:
xor eax, eax
ret
has_C_nodes(node const*): # @has_C_nodes(node const*)
test rdi, rdi
je .LBB1_1
mov eax, 3
.LBB1_3: # =>This Inner Loop Header: Depth=1
mov rdi, qword ptr [rdi]
add eax, -1
test rdi, rdi
jne .LBB1_3
test eax, eax
sete al
ret
.LBB1_1:
xor eax, eax
ret
C == 1 case could be also solved with loop deletion pass?
<a href="https://godbolt.org/z/do656c17b">https://godbolt.org/z/do656c17b</a></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>