jdk
jdk copied to clipboard
8293833: Error mixing types with -XX:+UseCMoveUnconditionally -XX:+UseVectorCmov
After JDK-8139340, JDK-8192846 and JDK-8289422, we can vectorize the case below by enabling -XX:+UseCMoveUnconditionally and -XX:+UseVectorCmov:
// double[] a, double[] b, double[] c;
for (int i = 0; i < a.length; i++) {
c[i] = (a[i] > b[i]) ? a[i] : b[i];
}
But we don't support the case like:
// double[] a;
// int seed;
for (int i = 0; i < a.length; i++) {
a[i] = (i % 2 == 0) ? seed + i : seed - i;
}
because the IR nodes for the CMoveD in the loop is:
AddI AndI AddD SubD
\ / / /
CmpI / /
\ / /
Bool / /
\ / /
CMoveD
and it is not our target pattern, which requires that the inputs of Cmp node must be the same as the inputs of CMove node as commented in CMoveKit::make_cmovevd_pack(). Because we can't vectorize the CMoveD pack, we shouldn't vectorize its inputs, AddD and SubD. But the current function CMoveKit::make_cmovevd_pack() doesn't clear the unqualified CMoveD pack from the packset. In this way, superword wrongly vectorizes AddD and SubD. Finally, we get a scalar CMoveD node with two vector inputs, AddVD and SubVD, which has wrong mixing types, then the assertion fails.
To fix it, we need to remove the unvectorized CMoveD pack from the packset and clear related map info.
Progress
- [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
- [x] Change must not contain extraneous whitespace
- [x] Commit message must refer to an issue
Issue
- JDK-8293833: Error mixing types with -XX:+UseCMoveUnconditionally -XX:+UseVectorCmov
Reviewers
- Christian Hagedorn (@chhagedorn - Reviewer)
Reviewing
Using git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10627/head:pull/10627
$ git checkout pull/10627
Update a local copy of the PR:
$ git checkout pull/10627
$ git pull https://git.openjdk.org/jdk pull/10627/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10627
View PR using the GUI difftool:
$ git pr show -t 10627
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10627.diff
:wave: Welcome back fgao! A progress list of the required criteria for merging this PR into master
will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.
@fg1417 The following label will be automatically applied to this pull request:
-
hotspot-compiler
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.
Webrevs
- 03: Full - Incremental (f65118cc)
- 02: Full - Incremental (47ca7341)
- 01: Full - Incremental (a113675d)
- 00: Full (1b615da3)
May I ask if we can vectorise Bool -> Cmp
into VectorMaskCmp
and CMove
into VectorBlend
, this would help vectorise the pattern you mention in the description instead of bailing out? Thanks.
May I ask if we can vectorise
Bool -> Cmp
intoVectorMaskCmp
andCMove
intoVectorBlend
, this would help vectorise the pattern you mention in the description instead of bailing out? Thanks.
@merykitty Thanks for your kind review and question.
That's really an interesting idea. IMO, vectorizing Bool -> Cmp
and CMove
separately, to support more cases, deserves a deep investigation. I'm not sure if it's feasible. But for the case in the description, even trying the idea, we still can't vectorize the case because we can't vectorize i % 2
currently. In this way, we can't vectorize any chain involving i % 2
.
@fg1417 This change now passes all automated pre-integration checks.
ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.
After integration, the commit message for the final commit will be:
8293833: Error mixing types with -XX:+UseCMoveUnconditionally -XX:+UseVectorCmov
Reviewed-by: chagedorn, kvn
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.
At the time when this comment was updated there had been 96 new commits pushed to the master
branch:
- 529cc48f355523fd162470b416a5081869adcf0e: 8295396: RISC-V: Cleanup useless CompressibleRegions
- 692cdab2be7dfc6e12b127f8e2c97bc41536cb84: 8295016: Make the arraycopy_epilogue signature consistent with its usage
- 21a825e059170e3a069b9f0982737c5839e6dae2: 8288387: GetLocalXXX/SetLocalXXX spec should require suspending target thread
- 8d751de3198675b22704cdccafaff2fc0fdd3f59: 8295231: Move all linking of native libraries to make
- f300ec8631b781938e6e96165ba23cda14a20f24: 8294546: document where javac differs when invoked via launcher and ToolProvider
- b269c51d10c353d9b7143b2239beb23c01352182: 8295395: Linux Alpha Zero builds fail after JDK-8292591
- ae60599e2ba75d80c3b4279903137b2c549f8066: 8295023: Interpreter(AArch64): Implement -XX:+PrintBytecodeHistogram and -XX:+PrintBytecodePairHistogram options
- 4d37ef2d545c016e6c3ad52171ea961d4406726f: 8295262: Build binutils out of source tree
- 0919a3a0c198a5234b5ed9a3bb999564d2382a56: 8294186: AArch64: VectorMaskToLong failed on SVE2 machine with -XX:UseSVE=1
- ec2981b83bc3ef6977b5f16d5222eb49b0ea49ad: 8293711: Factor out size parsing functions from arguments.cpp
- ... and 86 more: https://git.openjdk.org/jdk/compare/97f1321cb455b536f1e4e056dec693c24f39d641...master
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@chhagedorn, @vnkozlov) but any other Committer may sponsor as well.
➡️ To flag this PR as ready for integration with the above commit message, type /integrate
in a new comment. (Afterwards, your sponsor types /sponsor
in a new comment to perform the integration).
@chhagedorn thanks for your review and comments! I updated the commit to resolve the code style issue.
Thanks for the update, looks good and testing passed!
@chhagedorn thanks for your review and test work!
Does
compiler/c2/irTests/TestVectorConditionalMove.java
IR test cover this case? Can you add it if it is not already?
Thanks for pointing it out @vnkozlov . Updated the IR testcase in the new commit.
Thanks all for your review and comments. I'll integrate it.
/integrate
@fg1417 Your change (at version f65118cc7f5088cfbf164eed8cf676fc6dd8548c) is now ready to be sponsored by a Committer.
/sponsor
Going to push as commit 490fcd0c2547cb4e564363f0cd121c777c3acc02.
Since your change was applied there have been 96 commits pushed to the master
branch:
- 529cc48f355523fd162470b416a5081869adcf0e: 8295396: RISC-V: Cleanup useless CompressibleRegions
- 692cdab2be7dfc6e12b127f8e2c97bc41536cb84: 8295016: Make the arraycopy_epilogue signature consistent with its usage
- 21a825e059170e3a069b9f0982737c5839e6dae2: 8288387: GetLocalXXX/SetLocalXXX spec should require suspending target thread
- 8d751de3198675b22704cdccafaff2fc0fdd3f59: 8295231: Move all linking of native libraries to make
- f300ec8631b781938e6e96165ba23cda14a20f24: 8294546: document where javac differs when invoked via launcher and ToolProvider
- b269c51d10c353d9b7143b2239beb23c01352182: 8295395: Linux Alpha Zero builds fail after JDK-8292591
- ae60599e2ba75d80c3b4279903137b2c549f8066: 8295023: Interpreter(AArch64): Implement -XX:+PrintBytecodeHistogram and -XX:+PrintBytecodePairHistogram options
- 4d37ef2d545c016e6c3ad52171ea961d4406726f: 8295262: Build binutils out of source tree
- 0919a3a0c198a5234b5ed9a3bb999564d2382a56: 8294186: AArch64: VectorMaskToLong failed on SVE2 machine with -XX:UseSVE=1
- ec2981b83bc3ef6977b5f16d5222eb49b0ea49ad: 8293711: Factor out size parsing functions from arguments.cpp
- ... and 86 more: https://git.openjdk.org/jdk/compare/97f1321cb455b536f1e4e056dec693c24f39d641...master
Your commit was automatically rebased without conflicts.
@nsjian @fg1417 Pushed as commit 490fcd0c2547cb4e564363f0cd121c777c3acc02.
:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.