Here follows a listing of the optimizing techniques used in the compiler:
Although you can enable uncertain optimizations in most cases, for people who do not understand the following technical explanation, it might be the safest to leave them off.
Remark:If uncertain optimizations are enabled, the CSE algorithm assumes that
The practical upshot of this is that you cannot use the uncertain optimizations if you both write and read local or global variables directly and through pointers (this includes Var parameters, as those are pointers too).
The following example will produce bad code when you switch on uncertain optimizations:
The reason it produces bad code is because you access the global variable Temp both through its name Temp and through a pointer, in this case using the Bar variable parameter, which is nothing but a pointer to Temp in the above code.
On the other hand, you can use the uncertain optimizations if you access global/local variables or parameters through pointers, and only access them through this pointer1.
Will produce correct code, because the global variable MyRecArrayPtr is not accessed directly, but only through a pointer (MyRecPtr in this case).
In conclusion, one could say that you can use uncertain optimizations only when you know what you’re doing.
1You can use multiple pointers to point to the same variable as well, that doesn’t matter.