Z: short circuit ArrayCmpLen if addresses are equal - #7222
Merged
hzongaro merged 1 commit intoFeb 1, 2024
Conversation
Updated arraycmplen to short circuit if comparing the same array Two arrays are equal if their addresses are equal Added branch instruction to jump to return in this case Signed-off-by: Ehsan Kiani Far <ehsan.kianifar@gmail.com>
Contributor
Author
|
Tested for JDK8 (LoZ and zOS) Axxon 63769, test level.sanity, all tests pass |
Contributor
Author
|
Instruction selection: |
ehsankianifar
commented
Jan 10, 2024
| dependencies->addPostCondition(orgLen, TR::RealRegister::AssignAny); | ||
| dependencies->addPostCondition(resultReg, TR::RealRegister::AssignAny); | ||
|
|
||
| generateRRInstruction(cg, TR::InstOpCode::getLoadRegOpCode(), node, resultReg, orgLen); |
Contributor
Author
There was a problem hiding this comment.
if the arrays are equal, we return the length in this method
ehsankianifar
commented
Jan 10, 2024
| cg->decReferenceCount(elemsExpr); | ||
| cg->decReferenceCount(firstBaseAddr); | ||
| cg->decReferenceCount(secondBaseAddr); | ||
| cursor->setDependencyConditions(dependencies); |
Contributor
Author
There was a problem hiding this comment.
dependency conditions added to the cFlowRegionEnd label
r30shah
approved these changes
Jan 12, 2024
r30shah
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks for the change.
Contributor
|
Jenkins build zos,zlinux |
1 similar comment
Contributor
|
Jenkins build zos,zlinux |
Contributor
|
@hzongaro Can I request you to merge this change if you are OK with it ? |
Contributor
|
x86-64 macOS failure is unrelated to this change. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the addresses of two arrays are equal, those two arrays are considered equal and we do not need to actually compare those arrays. In this PR, we modified the instructions for x86 and there was a discussion to do the same for other architectures. On Z, it is more complicated and depending on the conditions and expected response, several methods implement array compare.
This PR targets array cmp len implementation. If the Array cmp asks for the position of the first mismatch, this implementation would be called. It returns the index of the fists mismatch or the length of the array if there is no mismatch.