We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all,
I tried compiling some sanity-checking example code on an evaluation copy I installed today and got some unexpected results; seemingly no matter what I set the code optimization level to (using the C51 tab in the Options for Target dialog) I get very little optimization in the object code - less than I'd expect, anyhow.
The code I've been testing with is as follows:
static res; void unused() { res = 2 * 2; } int main() { int i =2 , j=3, k=4; i *=i * i; k = (j * j) * (j * j) * i; res = k; return k; }
I expected this to basically optimize away to simply MOV a constant into place. Also, I expected the unused function to be eliminated. I'm not generally seeing this - the unused function is present when I view the assembly output in the debugger. There are multiplies still in the code, although it might have elimated one or two of them.
Am I missing something here? Changing the optimization level does seem to have some effect on the size of the binary produced, so it's doing something. Are there more switches somewhere I need to flip?
I feel your pain. At some point I just stopped looking at the code C51 produces - it was too much to bear. It appears that in terms of compiler technology C51 is stuck in the distant past. You certainly would expect a lot more from a modern compiler...