<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 - Potential improvement for checking if condition on ARM32"
href="https://bugs.llvm.org/show_bug.cgi?id=37452">37452</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Potential improvement for checking if condition on ARM32
</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>Keywords</th>
<td>performance
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: ARM
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lidija.besker@rt-rk.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mips32r2@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>I have been looking into functions compiled for ARM32 and I noticed a excess
instructions in results generated by LLVM. In function foo value in R0 is
checked whether it is 0 and only in case when it is 0 is set to 0 (cmp and
moveq instructions). Objdump of test case given below was compiled with
optimization for size.
For example:
typedef struct k
{
int m;
int n;
} str_k;
extern str_k* bar(str_k* a, int b);
int foo(str_k* a, int b){
if(a == NULL) return 0;
bar(a, b);
return b-a->n;
}
clang generated:
00000000 <foo>:
0: e3500000 cmp r0, #0
4: 03a00000 moveq r0, #0
8: 012fff1e bxeq lr
c: e92d4830 push {r4, r5, fp, lr}
10: e28db008 add fp, sp, #8
14: e1a04001 mov r4, r1
18: e1a05000 mov r5, r0
1c: ebfffffe bl 0 <bar>
20: e5950004 ldr r0, [r5, #4]
24: e0440000 sub r0, r4, r0
28: e8bd4830 pop {r4, r5, fp, lr}
2c: e12fff1e bx lr
Not a big difference but expanding condition will cause it to get worse, so
fixing this should improve the code size.</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>