Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YJIT: Merge lea and mov on x86_64 when possible #7453

Merged
merged 2 commits into from Mar 7, 2023

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Mar 6, 2023

I started to look into adding optimization passes to the backend. This was one of the inefficient code I was aware of, so I worked on this first. My plan is to add more peephole optimizations to x86_merge over time.

Generated code

Before

  # save SP to CFP
  0x564019e65142: lea rcx, [rbx - 0x10]
  0x564019e65146: mov rbx, rcx
  0x564019e65149: mov qword ptr [r13 + 8], rbx

After

  # save SP to CFP
  0x5634800c413f: lea rbx, [rbx - 0x10]
  0x5634800c4143: mov qword ptr [r13 + 8], rbx

Code size stats

On railsbench, inline code size went down by 0.4%. I see no significant impact on its speed.

Before

inline_code_size:          2,073,884
outlined_code_size:        2,073,528

After

inline_code_size:          2,065,752
outlined_code_size:        2,065,384

@k0kubun k0kubun marked this pull request as ready for review March 7, 2023 00:27
@matzbot matzbot requested a review from a team March 7, 2023 00:27
Copy link
Contributor

@maximecb maximecb left a comment

Choose a reason for hiding this comment

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

I wrote some very minor comments. Seems ready to merge otherwise.

We do have to be somewhat careful about adding many passes to the compiler as this will slow down our compilation speed. For now seems like not a huge concern, but something to keep in mind, especially since we aren't tracking compilation speed right now.

@k0kubun k0kubun merged commit 3e731cd into ruby:master Mar 7, 2023
@k0kubun k0kubun deleted the yjit-backend-lea branch March 7, 2023 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants