Skip to content

8386163: C2 Vector API: assert(collect_unique_inputs(n, inputs) == 1) failed: not unary#31626

Open
jatin-bhateja wants to merge 2 commits into
openjdk:masterfrom
jatin-bhateja:JDK-8386163
Open

8386163: C2 Vector API: assert(collect_unique_inputs(n, inputs) == 1) failed: not unary#31626
jatin-bhateja wants to merge 2 commits into
openjdk:masterfrom
jatin-bhateja:JDK-8386163

Conversation

@jatin-bhateja

@jatin-bhateja jatin-bhateja commented Jun 23, 2026

Copy link
Copy Markdown
Member

This patch fixes an assertion failure seen in macro logic optimization caused by collect_unique_inputs mishandling of the bitwise-not pattern XorV(operand, -1) when the negated operand was itself an all-ones vector, i.e. XorV(-1, -1). It skipped all all-ones operands, collecting zero inputs instead of one, which tripped an assertion failure. The fix makes input collection select the single negated operand, so exactly one input is collected.

Kindly review and share your feedback.

Best Regards,
Jatin



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8386163: C2 Vector API: assert(collect_unique_inputs(n, inputs) == 1) failed: not unary (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31626/head:pull/31626
$ git checkout pull/31626

Update a local copy of the PR:
$ git checkout pull/31626
$ git pull https://git.openjdk.org/jdk.git pull/31626/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31626

View PR using the GUI difftool:
$ git pr show -t 31626

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31626.diff

Using Webrev

Link to Webrev Comment

@jatin-bhateja

Copy link
Copy Markdown
Member Author

/label add hotspot-compiler-dev

@bridgekeeper

bridgekeeper Bot commented Jun 23, 2026

Copy link
Copy Markdown

👋 Welcome back jbhateja! 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.

@openjdk

openjdk Bot commented Jun 23, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 23, 2026
@openjdk

openjdk Bot commented Jun 23, 2026

Copy link
Copy Markdown

@jatin-bhateja
The hotspot-compiler label was successfully added.

@openjdk

openjdk Bot commented Jun 23, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-compiler. This can be overridden with the /reviewers command.

@openjdk

openjdk Bot commented Jun 23, 2026

Copy link
Copy Markdown

@jatin-bhateja To determine the appropriate audience for reviewing this pull request, one or more labels corresponding to different subsystems will normally be applied automatically. However, no automatic labelling rule matches the changes in this pull request. In order to have an "RFR" email sent to the correct mailing list, you will need to add one or more applicable labels manually using the /label pull request command.

Applicable Labels
  • build
  • client
  • compiler
  • core-libs
  • hotspot
  • hotspot-compiler
  • hotspot-gc
  • hotspot-jfr
  • hotspot-runtime
  • i18n
  • ide-support
  • javadoc
  • jdk
  • net
  • nio
  • security
  • serviceability
  • shenandoah

@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 23, 2026
@mlbridge

mlbridge Bot commented Jun 23, 2026

Copy link
Copy Markdown

Webrevs

@@ -2721,13 +2721,10 @@ static uint collect_unique_inputs(Node* n, Unique_Node_List& inputs) {
if (is_vector_bitwise_op(n)) {
uint inp_cnt = n->is_predicated_vector() ? n->req()-1 : n->req();
if (VectorNode::is_vector_bitwise_not_pattern(n)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can VectorNode::is_vector_bitwise_not_pattern return the operand that is noted, so its caller does not need to find that information itself?

@jatin-bhateja jatin-bhateja Jun 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I preferred fixing existing detection logic after the call to is_vector_bitwise_not_pattern which skip over both all ones operand. currently is_vector_bitwise_not_pattern returns a bool value, making the change you suggested will lead to a change (retValue != nullptr) at all the existing call sites of is_vector_bitwise_not_pattern.

Comment thread test/hotspot/jtreg/compiler/vectorapi/TestMaskedNotAllOnes.java Outdated
@eme64

eme64 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

FYI: just found this bug while reviewing ;)

JDK-8387145

@iwanowww iwanowww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good.

Comment thread test/hotspot/jtreg/compiler/vectorapi/TestMaskedNotAllOnes.java Outdated
Comment thread src/hotspot/share/opto/compile.cpp
@@ -2721,13 +2721,10 @@ static uint collect_unique_inputs(Node* n, Unique_Node_List& inputs) {
if (is_vector_bitwise_op(n)) {
uint inp_cnt = n->is_predicated_vector() ? n->req()-1 : n->req();
if (VectorNode::is_vector_bitwise_not_pattern(n)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this code also check is_vectormask_bitwise_not_pattern()? It looks like VectorNode::make_mask_node() can create either kind, depending on platform support.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collect_unique_inputs is only ever called on nodes for which is_vector_bitwise_op(n) holds, and that helper is restricted to Op_XorV / Op_AndV / Op_OrV / Op_MacroLogicV — it does not include the *VMask opcodes. So a genuine XorVMaskNode never enters the macro-logic cone optimization at all.

@eme64

eme64 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

And found yet another bug in logic cones, while reviewing: JDK-8387204

I'm a bit disappointed in how many bugs I can find here. I think testing isn't very good for this optimization 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

5 participants