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

Rewrite the int128 clamp to avoid a branch #2411

Merged
merged 1 commit into from
Aug 9, 2021

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Aug 8, 2021

and also avoid direct manipulation of the stack

I guess this isn't as important now that the standard is to use int256.

How I did it

Bit twiddling

How to verify it

Tests still pass

Description for the changelog

Increase efficiency of int128 clamps

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

and also avoid direct manipulation of the stack.

Per-clamp, this uses 5 fewer bytes (in the bytecode) and 11 fewer gas
@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2021

Codecov Report

Merging #2411 (febc8c6) into master (b52715e) will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2411      +/-   ##
==========================================
+ Coverage   85.47%   85.51%   +0.03%     
==========================================
  Files          91       91              
  Lines        9034     9034              
  Branches     2151     2151              
==========================================
+ Hits         7722     7725       +3     
+ Misses        806      804       -2     
+ Partials      506      505       -1     
Impacted Files Coverage Δ
vyper/old_codegen/arg_clamps.py 100.00% <ø> (ø)
vyper/builtin_functions/functions.py 88.68% <0.00%> (+0.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b52715e...febc8c6. Read the comment docs.

@charles-cooper charles-cooper marked this pull request as ready for review August 9, 2021 01:01
Copy link
Contributor

@iamdefinitelyahuman iamdefinitelyahuman left a comment

Choose a reason for hiding this comment

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

Looks good. And the clamping is well tested so if there was an issue we'd see failing tests.

@fubuloubu fubuloubu merged commit c9bde12 into vyperlang:master Aug 9, 2021
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

4 participants