[Interest] armv7a-hard-float in Qt android apps

Ola Røer Thorsen ola at silentwings.no
Sat Apr 30 11:51:06 CEST 2016


2016-04-30 10:46 GMT+02:00 Jean-Michaël Celerier <
jeanmichael.celerier at gmail.com>:

> https://godbolt.org/g/DqBlFG
>
> With gcc -O1
>
> float f(float x)
> {
>   return 2. * x;
> }
>
> becomes
>
> f(float):
>         addss   %xmm0, %xmm0
>         ret
>
>
> and
>
> float g (float x)
> {
>   return 2.f * x;
> }
>
> becomes
>
> g(float):
>         addss   %xmm0, %xmm0
>         ret
>
>
This is on x86. I was talking about ARM with single-precision FPUs and the
general advice not to use double precision constants if possible there.

This is what GCC itself says in the documentation for -Wdouble-promotion:

-Wdouble-promotion (C, C++, Objective-C and Objective-C++ only)Give a
warning when a value of type float is implicitly promoted to double. CPUs
with a 32-bit “single-precision” floating-point unit implement float in
hardware, but emulate double in software. On such a machine, doing
computations using double values is much more expensive because of the
overhead required for software emulation.

It is easy to accidentally do computations with double because
floating-point literals are implicitly of type double. For example, in:

          float area(float radius)
          {
             return 3.14159 * radius * radius;
          }

the compiler performs the entire computation with double because the
floating-point literal is a double.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160430/83589111/attachment.html>


More information about the Interest mailing list