Skip to content

Don't version BNDCHK based on an IV if the loop test is backwards - #7250

Merged
vijaysun-omr merged 1 commit into
eclipse-omr:masterfrom
jdmpapin:fix18803
Feb 9, 2024
Merged

Don't version BNDCHK based on an IV if the loop test is backwards#7250
vijaysun-omr merged 1 commit into
eclipse-omr:masterfrom
jdmpapin:fix18803

Conversation

@jdmpapin

@jdmpapin jdmpapin commented Feb 6, 2024

Copy link
Copy Markdown
Contributor

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.

Fixes eclipse-openj9/openj9#18803

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.
@jdmpapin

jdmpapin commented Feb 6, 2024

Copy link
Copy Markdown
Contributor Author

@vijaysun-omr, would you mind reviewing?

@vijaysun-omr

Copy link
Copy Markdown
Contributor

jenkins build all

@vijaysun-omr

Copy link
Copy Markdown
Contributor

jenkins build riscv

@vijaysun-omr

Copy link
Copy Markdown
Contributor

Failures look to be infra related. The change itself looks conservative/safe to me and in common code. Merging.

@vijaysun-omr
vijaysun-omr merged commit 92e1304 into eclipse-omr:master Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JDK 11/17/21 - Missing ArrayIndexOutOfBoundsException in a loop, and instead incorrectly throwing NullPointerException

2 participants