This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
floating point constants on arm
- To: gcc-bugs at gcc dot gnu dot org
- Subject: floating point constants on arm
- From: Philip Blundell <Philip dot Blundell at pobox dot com>
- Date: Mon, 24 Apr 2000 21:14:04 +0100
This code is distilled from the Linux kernel:
int f(int yTL)
{
const double fixScale=1.0*256*256;
const int yScale=(int)(fixScale);
return yTL * yScale;
}
Floating point doesn't work inside the kernel. The author's expectation was
clearly that GCC would perform the arithmetic and cast it to an int at
compile time, so that only an integer multiply is needed at runtime.
Unfortunately, an arm-linux targeted compiler built from the current trunk
code generates the double->int conversion at run time:
stmfd sp!, {r4, lr}
mov r4, r0
adr r0, .L3
ldmia r0, {r0-r1}
bl __fixdfsi
mul r0, r4, r0
ldmfd sp!, {r4, pc}
.L4:
.align 2
.L3:
.long 0x40f00000, 0x0 @ double 6.55360000000000000000e4
which is not only slower but actually fails in this situation.
p.