Skip to content

Conversation

@vladimirradosavljevic
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Jun 18, 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                              -2.222 ║
║ Total                              -0.000 ║
╠═╡ Ergs (-%) ╞════════════════╡ All MzB3 ╞═╣
║ Mean                               -0.000 ║
║ Best                                0.000 ║
║ Worst                              -1.247 ║
║ Total                              -0.000 ║
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════╡ EVMInterpreter M3B3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╠═╡ 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                                66.750 ║
║ MUL                                38.850 ║
║ SUB                                66.750 ║
║ DIV                                47.250 ║
║ SDIV                               64.050 ║
║ MOD                                46.050 ║
║ SMOD                               61.650 ║
║ ADDMOD                             35.656 ║
║ MULMOD                             35.656 ║
║ EXP                                 8.838 ║
║ SIGNEXTEND                         44.850 ║
║ LT                                 70.750 ║
║ GT                                 70.750 ║
║ SLT                                94.750 ║
║ SGT                                92.750 ║
║ EQ                                 70.750 ║
║ ISZERO                             62.417 ║
║ AND                                64.750 ║
║ OR                                 66.750 ║
║ XOR                                66.750 ║
║ NOT                                58.417 ║
║ BYTE                               74.750 ║
║ SHL                                72.750 ║
║ SHR                                70.750 ║
║ SAR                                88.750 ║
║ SGT                                92.750 ║
║ SHA3                               28.647 ║
║ ADDRESS                            90.000 ║
║ BALANCE                            73.585 ║
║ ORIGIN                           1381.562 ║
║ CALLER                             90.000 ║
║ CALLVALUE                          90.000 ║
║ CALLDATALOAD                       60.750 ║
║ CALLDATASIZE                       90.125 ║
║ CALLDATACOPY                       70.200 ║
║ CODESIZE                           90.625 ║
║ CODECOPY                          145.226 ║
║ GASPRICE                         1384.188 ║
║ EXTCODESIZE                         5.107 ║
║ EXTCODECOPY                         5.199 ║
║ RETURNDATASIZE                     85.500 ║
║ RETURNDATACOPY                     54.444 ║
║ EXTCODEHASH                         8.342 ║
║ BLOCKHASH                         243.719 ║
║ COINBASE                         1384.562 ║
║ TIMESTAMP                        1381.562 ║
║ NUMBER                           1381.562 ║
║ PREVRANDAO                       1381.562 ║
║ GASLIMIT                         1387.562 ║
║ CHAINID                          1381.562 ║
║ SELFBALANCE                       653.250 ║
║ BASEFEE                          1378.562 ║
║ POP                                77.625 ║
║ MLOAD                              77.637 ║
║ MSTORE                             81.402 ║
║ MSTORE8                            87.363 ║
║ SLOAD                              27.086 ║
║ SSTORE                              9.059 ║
║ JUMP                               35.778 ║
║ JUMPI                              31.545 ║
║ PC                                 90.500 ║
║ MSIZE                              97.000 ║
║ GAS                                84.500 ║
║ JUMPDEST                          120.000 ║
║ PUSH0                              87.500 ║
║ PUSH1                              66.083 ║
║ PUSH2                              69.500 ║
║ PUSH4                              72.333 ║
║ PUSH5                              73.750 ║
║ PUSH6                              75.167 ║
║ PUSH7                              76.583 ║
║ PUSH8                              78.000 ║
║ PUSH9                              79.417 ║
║ PUSH10                             80.833 ║
║ PUSH11                             82.250 ║
║ PUSH12                             83.667 ║
║ PUSH13                             85.083 ║
║ PUSH14                             86.500 ║
║ PUSH15                             87.917 ║
║ PUSH16                             89.333 ║
║ PUSH17                             90.750 ║
║ PUSH18                             92.167 ║
║ PUSH19                             93.583 ║
║ PUSH20                             95.000 ║
║ PUSH21                             96.417 ║
║ PUSH22                             97.833 ║
║ PUSH23                             99.250 ║
║ PUSH24                            100.667 ║
║ PUSH25                            102.083 ║
║ PUSH26                            103.500 ║
║ PUSH27                            104.917 ║
║ PUSH28                            106.333 ║
║ PUSH29                            107.750 ║
║ PUSH30                            109.167 ║
║ PUSH31                            110.583 ║
║ PUSH32                            110.000 ║
║ DUP1                               60.417 ║
║ DUP2                               64.417 ║
║ DUP3                               64.417 ║
║ DUP4                               64.417 ║
║ DUP5                               64.417 ║
║ DUP6                               64.417 ║
║ DUP7                               64.417 ║
║ DUP8                               64.417 ║
║ DUP9                               62.417 ║
║ DUP10                              64.417 ║
║ DUP11                              64.417 ║
║ DUP12                              64.417 ║
║ DUP13                              64.417 ║
║ DUP14                              64.417 ║
║ DUP15                              64.417 ║
║ DUP16                              64.417 ║
║ SWAP1                              65.083 ║
║ SWAP2                              65.083 ║
║ SWAP3                              65.083 ║
║ SWAP4                              65.083 ║
║ SWAP5                              65.083 ║
║ SWAP6                              65.083 ║
║ SWAP7                              65.083 ║
║ SWAP8                              65.083 ║
║ SWAP9                              65.083 ║
║ SWAP10                             65.083 ║
║ SWAP11                             65.083 ║
║ SWAP12                             65.083 ║
║ SWAP13                             65.083 ║
║ SWAP14                             65.083 ║
║ SWAP15                             65.083 ║
║ SWAP16                             63.083 ║
║ CALL                               63.065 ║
║ STATICCALL                         63.028 ║
║ DELEGATECALL                       62.071 ║
║ CREATE                              5.507 ║
║ CREATE2                             7.770 ║
║ RETURN                              1.000 ║
║ REVERT                              1.000 ║
╠═╡ Ergs/gas (-%) ╞═╡ EVMInterpreter M3B3 ╞═╣
╚═══════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════╡ EVMInterpreter MzB3 ╞═╗
║ Mean                                0.000 ║
║ Best                                0.000 ║
║ Worst                               0.000 ║
║ Total                                 NaN ║
╠═╡ 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 added a commit that referenced this pull request Jun 18, 2024
This patch fixes the issue where uadd overflow
intrinsic is matched for:
`Add = add A,(uint64_t)-1; Cmp = icmp ne A, 0`
instead of:
`Add = add A,-1; Cmp = icmp ne A, 0`
where -1 is represented in 256 bits.

PR: #626

Signed-off-by: Vladimir Radosavljevic <[email protected]>
@vladimirradosavljevic vladimirradosavljevic force-pushed the fix_cgp_uadd_overflow_matching branch from 6496869 to c9e4418 Compare June 18, 2024 09:49
@github-actions
Copy link

github-actions bot commented Jun 18, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

vladimirradosavljevic added a commit that referenced this pull request Jun 18, 2024
This patch fixes the issue where uadd overflow
intrinsic is matched for:
`Add = add A,(uint64_t)-1; Cmp = icmp ne A, 0`
instead of:
`Add = add A,-1; Cmp = icmp ne A, 0`
where -1 is represented in 256 bits.

PR: #626

Signed-off-by: Vladimir Radosavljevic <[email protected]>
@vladimirradosavljevic vladimirradosavljevic force-pushed the fix_cgp_uadd_overflow_matching branch from c9e4418 to 7cfc8ab Compare June 18, 2024 09:56
Copy link
Collaborator

@akiramenai akiramenai left a comment

Choose a reason for hiding this comment

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

It should be upsteamable, shouldn't it? E.g. we don't need i256 target to test this code, a test can be put to generic codegen tests or something.

Add tests where uadd overflow intrinsic is matched for:
`Add = add A,(uint64_t)-1; Cmp = icmp ne A, 0`
instead of:
`Add = add A,-1; Cmp = icmp ne A, 0`
where -1 is represented in 256 bits.

Signed-off-by: Vladimir Radosavljevic <[email protected]>
This patch fixes the issue where uadd overflow
intrinsic is matched for:
`Add = add A,(uint64_t)-1; Cmp = icmp ne A, 0`
instead of:
`Add = add A,-1; Cmp = icmp ne A, 0`
where -1 is represented in 256 bits.

PR: #626

Signed-off-by: Vladimir Radosavljevic <[email protected]>
@vladimirradosavljevic vladimirradosavljevic force-pushed the fix_cgp_uadd_overflow_matching branch from 7cfc8ab to 098d481 Compare June 19, 2024 08:42
@vladimirradosavljevic
Copy link
Contributor Author

It should be upsteamable, shouldn't it? E.g. we don't need i256 target to test this code, a test can be put to generic codegen tests or something.

Yes, this can be upstreamed. Unfortunately, there are only few generic CGP tests, others are in llvm/test/Transforms/CodeGenPrepare/TargetName, so we can add the same test for ARM target to show the problem and the fix.

@vladimirradosavljevic
Copy link
Contributor Author

Closing in favor of #630.

@vladimirradosavljevic vladimirradosavljevic deleted the fix_cgp_uadd_overflow_matching branch June 19, 2024 13:30
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.

2 participants