Skip to content

Changes

Summary

  1. Don't version BNDCHK based on an IV if the loop test is backwards (commit: 2ad3b1c) (details)
Commit 2ad3b1c4334eafaf29f54087cc2941675a96e00e by Devin Papineau
Don't version BNDCHK based on an IV if the loop test is backwards

For an increasing loop-driving IV, the loop test must impose an upper
bound, e.g. while (i < n), whereas for a decreasing loop-driving IV, the
loop test must impose a lower bound instead, e.g. while (i >= n).
Otherwise, the predicted maximum iteration count will be wrong, which
could allow a bound check to be incorrectly skipped.

Loop versioner will now check to ensure that the direction of the loop
test agrees with the sign of the step of the loop-driving IV.
(commit: 2ad3b1c)
The file was modified compiler/optimizer/LoopVersioner.cpp (diff)