if I have the following code:
int p=something
int l=somethingelse
int sum=0;
for(int i=0;i<p-l;i++)
sum+=(~i)^2+1337
can I generally assume the compiler optimizes the code so that p-l aren't recalculated every loop and is just cached since neither is changed in the loop? Or do I have to put p-l into a seperate variable if I want optimal performance?