<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 - ARM: inefficient repeated floating-point to int conversion"
href="https://bugs.llvm.org/show_bug.cgi?id=33199">33199</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ARM: inefficient repeated floating-point to int conversion
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gergo.barany@inria.fr
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18525" name="attach_18525" title="Input C file for triggering the issue">attachment 18525</a> <a href="attachment.cgi?id=18525&action=edit" title="Input C file for triggering the issue">[details]</a></span>
Input C file for triggering the issue
Simple test case:
$ cat tst.c
int fn1(double c, int *p) {
int i = (int) c;
*p = i;
return i;
}
On the source level, the double-to-int conversion is done once, but Clang
duplicates it in the generated code:
$ clang --target=armv7a-eabihf -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard
-O3 -S tst.c -o -
[...]
fn1:
.fnstart
@ BB#0:
vcvt.s32.f64 s2, d0
vcvt.s32.f64 s0, d0
vstr s2, [r0]
vmov r0, s0
bx lr
.Lfunc_end0:
[...]
This is for VFPv3, but it behaves identically with -mfpu=neon. A simple
duplication may not be a big deal, but the conversion is systematically
duplicated if I add more uses of the converted value:
$ cat tst.c
int fn1(double c, int *p, int *q, int *r, int *s) {
int i = (int) c;
*p = i;
*q = i;
*r = i;
*s = i;
return i;
}
$ clang --target=armv7a-eabihf -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard
-O3 -S tst.c -o -
[...]
vcvt.s32.f64 s2, d0
vstr s2, [r0]
vcvt.s32.f64 s2, d0
vstr s2, [r1]
vcvt.s32.f64 s2, d0
vstr s2, [r2]
vcvt.s32.f64 s2, d0
vcvt.s32.f64 s0, d0
vmov r0, s0
vstr s2, [r3]
bx lr
In all cases, GCC only does the conversion once.
$ clang --version
clang version 5.0.0 (trunk 303270)</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>