Skip to content

8354348: Enable Extended EVEX to REX2/REX demotion for commutative operations with same dst and src2#26997

Closed
vamsi-parasa wants to merge 9 commits intoopenjdk:masterfrom
vamsi-parasa:cdemotion
Closed

8354348: Enable Extended EVEX to REX2/REX demotion for commutative operations with same dst and src2#26997
vamsi-parasa wants to merge 9 commits intoopenjdk:masterfrom
vamsi-parasa:cdemotion

Conversation

@vamsi-parasa
Copy link
Contributor

@vamsi-parasa vamsi-parasa commented Aug 28, 2025

This change extends Extended EVEX (EEVEX) to REX2/REX demotion for Intel APX NDD instructions to handle commutative operations when the destination register and the second source register (src2) are the same.

Currently, EEVEX to REX2/REX demotion is only enabled when the first source (src1) and the destination are the same. This enhancement allows additional cases of valid demotion for commutative instructions (add, imul, and, or, xor).

For example:
eaddl r18, r25, r18 can be encoded as addl r18, r25 using APX REX2 encoding
eaddl r2, r7, r2 can be encoded as addl r2, r7 using non-APX legacy encoding


Progress

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

Issue

  • JDK-8354348: Enable Extended EVEX to REX2/REX demotion for commutative operations with same dst and src2 (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26997

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 28, 2025

👋 Welcome back sparasa! 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
Copy link

openjdk bot commented Aug 28, 2025

@vamsi-parasa 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:

8354348: Enable Extended EVEX to REX2/REX demotion for commutative operations with same dst and src2

Reviewed-by: jbhateja, epeter, sviswanathan

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 192 new commits pushed to the master branch:

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Aug 28, 2025

@vamsi-parasa 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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Aug 28, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 28, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 28, 2025

Webrevs

@jatin-bhateja
Copy link
Member

jatin-bhateja commented Sep 1, 2025

Hi @vamsi-parasa , thanks for working on this, I am process of validating #26283 and find that additional RA biasing will enable demotion for more cases, with a minimal test case I see following results

Test point:-
image
Baseline:-
image
With this patch:-
image
With additional RA biasing
image

instruct addI_rReg_mem_rReg_ndd(rRegI dst, memory src1, rRegI src2, rFlagsReg cr)
%{
predicate(UseAPX);
match(Set dst (AddI (LoadI src1) src2));
Copy link
Member

@jatin-bhateja jatin-bhateja Sep 2, 2025

Choose a reason for hiding this comment

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

Will this not be covered by the pattern at line 7103, since ADLC automatically generates a DFA to handle both cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will run experiments to make sure that the RegRegMem pattern also applies to RegMemReg case and remove the newly added match rules if they're redundant. Will update you soon.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @vamsi-parasa, your latest patch does not address this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Jatin (@jatin-bhateja), please see the latest update which removed the unnecessary match rules for RegMemReg case.

@vamsi-parasa
Copy link
Contributor Author

Hi @vamsi-parasa , thanks for working on this, I am process of validating #26283 and find that additional RA biasing will enable demotion for more cases, with a minimal test case I see following results

Hi Jatin (@jatin-bhateja), thank you for sharing the information about the register allocation biasing PR you're working on that will improve demotion.

Copy link

@sviswa7 sviswa7 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 9, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 11, 2025
@vamsi-parasa
Copy link
Contributor Author

vamsi-parasa commented Sep 11, 2025

Hi Emanuel (@eme64),

Could you please run the tests for this PR?

Thanks,
Vamsi

Copy link
Member

@jatin-bhateja jatin-bhateja left a comment

Choose a reason for hiding this comment

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

Hi @vamsi-parasa , Thanks for addressing my comments.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 11, 2025
@eme64
Copy link
Contributor

eme64 commented Sep 12, 2025

@vamsi-parasa Quickly scanned the patch, looks reasonable. Launching tests 🚀

@vamsi-parasa
Copy link
Contributor Author

@vamsi-parasa Quickly scanned the patch, looks reasonable. Launching tests 🚀

Hi Emanuel (@eme64), could you please let me know if the tests passed?

Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

Not reviewed in detail, but looks reasonable.
Tests pass :)

@vamsi-parasa
Copy link
Contributor Author

Not reviewed in detail, but looks reasonable. Tests pass :)

Thank you Emanuel! :)

@vamsi-parasa
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 16, 2025

Going to push as commit c41add8.
Since your change was applied there have been 203 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 16, 2025
@openjdk openjdk bot closed this Sep 16, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 16, 2025
@openjdk
Copy link

openjdk bot commented Sep 16, 2025

@vamsi-parasa Pushed as commit c41add8.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@vamsi-parasa
Copy link
Contributor Author

/backport openjdk/jdk25u

@openjdk
Copy link

openjdk bot commented Oct 20, 2025

@vamsi-parasa the backport was successfully created on the branch backport-vamsi-parasa-c41add8d-master in my personal fork of openjdk/jdk25u. To create a pull request with this backport targeting openjdk/jdk25u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c41add8d from the openjdk/jdk repository.

The commit being backported was authored by Srinivas Vamsi Parasa on 16 Sep 2025 and was reviewed by Jatin Bhateja, Emanuel Peter and Sandhya Viswanathan.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk25u:

$ git fetch https://github.com/openjdk-bots/jdk25u.git backport-vamsi-parasa-c41add8d-master:backport-vamsi-parasa-c41add8d-master
$ git checkout backport-vamsi-parasa-c41add8d-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk25u.git backport-vamsi-parasa-c41add8d-master

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 integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants