Remove Invariant Expressions from Loops
Expressions whose values do not change in a loop should be moved outside the loop. In the following loop:
FOR I = 0, N - 1 DO ARR(I, 2 * J - 1) = ...
the expression (2 * J - 1) is invariant and should be evaluated only once before the loop is entered:
TEMP = 2 * J - 1
FOR I = 0, N - 1 DO ARR(I, TEMP) = ...
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.