[llvm-bugs] [Bug 33199] New: ARM: inefficient repeated floating-point to int conversion
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun May 28 09:32:00 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33199
Bug ID: 33199
Summary: ARM: inefficient repeated floating-point to int
conversion
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: gergo.barany at inria.fr
CC: llvm-bugs at lists.llvm.org
Created attachment 18525
--> https://bugs.llvm.org/attachment.cgi?id=18525&action=edit
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)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170528/c9c88033/attachment-0001.html>
More information about the llvm-bugs
mailing list