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

[EraVM] Add support for select instructions in EraVMBytesToCells #536

Merged
merged 2 commits into from May 14, 2024

Conversation

vladimirradosavljevic
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented May 12, 2024

Benchmark results:

╔═╡ Size (-%) ╞════════════════╡ All M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞══════════════╡ All M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞════════════════╡ All M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞════════════════╡ All MzB3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞══════════════╡ All MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞════════════════╡ All MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞═══╡ EVMInterpreter M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs/gas ╞══════╡ EVMInterpreter M3B3 ╞═╣
║ ADD                                67.667 ║
║ MUL                                39.400 ║
║ SUB                                67.667 ║
║ DIV                                47.800 ║
║ SDIV                               64.600 ║
║ MOD                                46.600 ║
║ SMOD                               62.200 ║
║ ADDMOD                             39.000 ║
║ MULMOD                             36.000 ║
║ EXP                                 9.283 ║
║ SIGNEXTEND                         45.400 ║
║ LT                                 71.667 ║
║ GT                                 71.667 ║
║ SLT                                95.667 ║
║ SGT                                93.667 ║
║ EQ                                 71.667 ║
║ ISZERO                             63.333 ║
║ AND                                65.667 ║
║ OR                                 67.667 ║
║ XOR                                67.667 ║
║ NOT                                59.333 ║
║ BYTE                               75.667 ║
║ SHL                                73.667 ║
║ SHR                                71.667 ║
║ SAR                                89.667 ║
║ SGT                                93.667 ║
║ SHA3                               28.307 ║
║ ADDRESS                            91.000 ║
║ BALANCE                            73.180 ║
║ ORIGIN                           1443.875 ║
║ CALLER                             91.000 ║
║ CALLVALUE                          91.000 ║
║ BLOCKHASH                         244.450 ║
║ COINBASE                         1440.875 ║
║ TIMESTAMP                        1434.875 ║
║ NUMBER                           1434.875 ║
║ PREVRANDAO                       1434.875 ║
║ GASLIMIT                         1440.875 ║
║ CHAINID                          1428.875 ║
║ SELFBALANCE                       640.200 ║
║ BASEFEE                          1431.875 ║
║ POP                                79.000 ║
║ MLOAD                              75.611 ║
║ MSTORE                             77.389 ║
║ MSTORE8                            84.796 ║
║ SLOAD                              29.201 ║
║ SSTORE                              4.998 ║
║ JUMP                               37.333 ║
║ JUMPI                              32.818 ║
║ PC                                 91.500 ║
║ MSIZE                             101.000 ║
║ GAS                                85.500 ║
║ JUMPDEST                          122.000 ║
║ RETURN                              1.000 ║
║ REVERT                              1.000 ║
╠═╡ Ergs/gas (-%) ╞═╡ EVMInterpreter M3B3 ╞═╣
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════╡ EVMInterpreter MzB3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞═══╡ EVMInterpreter MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞═════╡ EVMInterpreter MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞════════╡ Precompiles M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞══════╡ Precompiles M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞════════╡ Precompiles M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞════════╡ Precompiles MzB3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞══════╡ Precompiles MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞════════╡ Precompiles MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞══════════╡ Real life M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞════════╡ Real life M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞══════════╡ Real life M3B3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞══════════╡ Real life MzB3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Cycles (-%) ╞════════╡ Real life MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╠═╡ Ergs (-%) ╞══════════╡ Real life MzB3 ╞═╣
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                               0.000 ║
╚═══════════════════════════════════════════╝

@vladimirradosavljevic vladimirradosavljevic force-pushed the add_select_bytes_to_cells branch 3 times, most recently from fd2e5d7 to 414bd7f Compare May 13, 2024 11:28
…in EraVMBytesToCells

Add tests where we fail to convert address
in select instructions to cells.

E.g. where r2 is not in cells:
```
add stack[r2], r0, r1
```
should be
```
shr.s 5, r2, r2
add stack[r2], r0, r1
```

Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
Since select instructions have stack and code operands,
we need to convert them into cell addressing. This patch
also adds IsEarlyClobber flag to select instructions in
which register is converted to cell addressing, to prevent
the regalloc from assigning output register to this register.

Without IsEarlyClobber flag:
```
shr.s 5, r2, r1
shr.s 5, r3, r2
add stack[r2], r0, r1
add.ne stack[r1], r0, r1
```
With IsEarlyClobber flag:
```
shr.s 5, r2, r2
shr.s 5, r3, r3
add stack[r3], r0, r1
add.ne stack[r2], r0, r1
```

Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
@akiramenai akiramenai merged commit e91f94b into main May 14, 2024
10 checks passed
@akiramenai akiramenai deleted the add_select_bytes_to_cells branch May 14, 2024 10:02
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

3 participants