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

feat: Introduce new mops for version 2 #321

Merged
merged 7 commits into from
Feb 9, 2023

Conversation

xxuejie
Copy link
Collaborator

@xxuejie xxuejie commented Feb 8, 2023

This change introduces 5 new mops for ckb-vm version 2. Those new mops all come from a direct observation of generated code from modern LLVM/GCC compilers. While they have less impact on secp256k1 contract(1183580 -> 1148321), they have more significant impact on complicated contracts. Using halo2 as an example:

  • The cycle consumption is reduced from 77309063 to 67521505
  • Actual runtime is reduced from 129ms to 111ms

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@xxuejie xxuejie requested a review from mohanson February 8, 2023 02:51
This won't reduce many cycles, the benefit is really that AUIPC is
historically treated as a basic block end instruction. By eliminating
AUIPC, we can expect longer sequential trace that aids execution.
The fixed version is included in version 2, version 1 is left unchanged
The fixed code will be included in version 2.
The fixed code is included in version 2.
@xxuejie xxuejie marked this pull request as ready for review February 9, 2023 01:57
ldr TEMP4, REGISTER_ADDRESS(RS2)
subs TEMP3, TEMP3, TEMP4
adc TEMP1, TEMP1, TEMP1
eor TEMP1, TEMP1, 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why xored TEMP1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

arm64 uses different borrow logic in subtraction here: when a borrow happened, the carry bit is 0, otherwise the carry bit is 1. This is the opposite of what we want, hence the xor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 6 to 12
li a0, 1
li a7, 93
ecall
1:
li a0, 0
li a7, 93
ecall
Copy link
Collaborator

Choose a reason for hiding this comment

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

These lines are useless, please delete them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants