I would like to optimize my C++ code for an ARM device, which lacks a floating point unit. Most of my functions use floats, and I am considering changing them to fixed-point.
Are there real benefits in the case of ARM devices, or are compilers smart enough to do this themselves?
For example, would this be more efficient on an ARM device
//unsigned char const* input
unsigned int a, b;
a= *input++ << 12;
b= *input++ << 12;
a*=1024; //0.25 shifted 12 bits
b*=1024; //0.25 shifted 12 bits
*output++ = (a+b) >> 24;
than doing
float a,b;
a= *input++;
b= *input++;
a=a/4;
b=a/4;
*output++ = a+b;