I have the following line of code:
#define A 360
#define B 360
temp = (s16_myvar * A) / B;
My compiler (Windriver DIAB PPC in this case, using standard extended optimization settings -XO) does not seem to optimize this away to something like temp = s16_myvar. When I look at the assembly listing, it seems to be faithfully putting 360 in a register and then after doing the multiply, dividing the result by 360.
Is there a trick I could use which would get rid of the multiply and divide in the final code?
And for those of you asking, "why?", suppose that in some configurations, B is not == A and you need to scale a variable.