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

Jean-Michaël Celerier jeanmichael.celerier at gmail.com
Sat Apr 30 10:46:21 CEST 2016


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


On Fri, Apr 29, 2016 at 6:30 PM, Ola Røer Thorsen <ola at silentwings.no>
wrote:

>
>
> 2016-04-29 16:36 GMT+02:00 Jean-Michaël Celerier <
> jeanmichael.celerier at gmail.com>:
>
>>
>> On Fri, Apr 29, 2016 at 1:55 PM, Ola Røer Thorsen <ola at silentwings.no>
>> wrote:
>>
>>>
>>> float a = 1.0f;
>>> float b = 2.0*a; // BAD!
>>> float b = 2.0f*a; // Good!
>>>
>>
>> Pretty sure that this would be a non-problem starting at -O1 optimization
>> level.
>>
>
> Well you're wrong. If you multiply with a double precision constant value
> (2.0), the multiplication is done in double precision and the result is
> then converted to single precision, regardless of the optimize level. This
> makes a big difference on hardware that only support single-precision in
> hardware (I know this from experience, not assumptions).
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160430/220922ff/attachment.html>


More information about the Interest mailing list