induction variable optimization

dean at ndmath.UUCP dean at ndmath.UUCP
Mon Feb 2 07:32:17 AEST 1987


In a recent Newsletter from Microsoft in Byte, the following is given as an
example of *induction variable optimization* :

     for(i=0;i<10;++i)   j += i*7;

     evaluates to:

     for(i=0;i<70;i += 7)  j += i;

Now, I may not understand what "evaluates to" means here, but it seems to me
that these statements are not equivalent, and following code which depends on
the value of i may not work correctly. Am I misunderstanding something?

     Dean Alvis   ( ...!ndmath!dean)



More information about the Comp.lang.c mailing list