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

"Optimize" GCC by removing const #279

Merged
merged 1 commit into from
Nov 30, 2022
Merged

"Optimize" GCC by removing const #279

merged 1 commit into from
Nov 30, 2022

Conversation

chfast
Copy link
Owner

@chfast chfast commented Nov 29, 2022

The bug in GCC prevents some optimizations if a local struct variable (like uint256) is const. This PR removes some consts that affects the optimization. See bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106786.

mod<addmod_public>/64                                         -0.1555         -0.1555            38            32            38            32
mod<addmod_public>/128                                        -0.0741         -0.0741            35            32            35            32
mod<addmod_public>/192                                        -0.1834         -0.1834            45            36            45            36
mod<addmod_public>/256                                        -0.1706         -0.1706            40            33            40            33
mod<mulmod>/64                                                -0.1329         -0.1329            55            47            55            47
mod<mulmod>/128                                               -0.1377         -0.1377            62            53            62            53
mod<mulmod>/192                                               -0.1233         -0.1233            77            68            77            68
mod<mulmod>/256                                               -0.1266         -0.1266            80            69            80            69
ecmod<addmod_public>                                          -0.7779         -0.7779            31             7            31             7
ecmod<mulmod>                                                 -0.1339         -0.1339            74            64            74            64
binop<uint256, uint256, public_mul>                           -0.0616         -0.0617             7             7             7             7
binop<uint512, uint256, umul_>                                -0.4201         -0.4201            19            11            19            11

The bug in GCC prevents some optimizations if a local struct variable
(like `uint256`) is `const`. This PR removes some `const`s that affects
the optimization.
See bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106786.
@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2022

Codecov Report

Merging #279 (2732d7f) into master (8b5f474) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #279   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         1941      1941           
=========================================
  Hits          1941      1941           
Flag Coverage Δ
32bit 100.00% <100.00%> (ø)
gcc 99.47% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/intx/intx.hpp 100.00% <100.00%> (ø)

@chfast chfast merged commit d2ce4df into master Nov 30, 2022
@chfast chfast deleted the opt_gcc branch November 30, 2022 11:50
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.

3 participants