<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 --- - [AArch64] Missed cbnz opportunity when compare value is known positive"
href="https://llvm.org/bugs/show_bug.cgi?id=30577">30577</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AArch64] Missed cbnz opportunity when compare value is known positive
</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>Backend: AArch64
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mcrosier@codeaurora.org
</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>Given the following test case:
void foo(int a, char *ptr) {
while (a > 0) {
*ptr++ = a & 0xff;
a >>= 8;
}
}
GCC generates:
foo:
cmp w0, 0
ble .L1
.p2align 2
.L5:
strb w0, [x1], 1
asr w0, w0, 8
cbnz w0, .L5
.L1:
ret
Clang generates:
foo: // @foo
// BB#0: // %entry
cmp w0, #1 // =1
b.lt .LBB0_2
.LBB0_1: // %while.body
// =>This Inner Loop Header: Depth=1
strb w0, [x1], #1
asr w0, w0, #8
cmp w0, #0 // =0
b.gt .LBB0_1
.LBB0_2: // %while.end
ret
In Clang's case, we should be able to replace the cmp + b.gt with a cbnz
because we know a will always be greater than zero if we execute the loop
(LBB0_1).</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>