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 ceil32 #2771

Merged
merged 3 commits into from
Apr 13, 2022
Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Apr 12, 2022

down from 9 to 6 instructions (all G_low)

also optimize out a couple instances of ceil32

What I did

steal a couple easy optimizations out of #2647

How I did it

note that ceil32(x) == floor32(x + 31)

How to verify it

tests still pass

Commit message

Description for the changelog

Cute Animal Picture

image

down from 9 to 6 instructions (all G_low)

also optimize out a couple instances of ceil32
@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2022

Codecov Report

Merging #2771 (eb6c9e9) into master (51bc1c2) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2771      +/-   ##
==========================================
- Coverage   87.44%   87.41%   -0.03%     
==========================================
  Files          93       93              
  Lines        9945     9949       +4     
  Branches     2471     2472       +1     
==========================================
+ Hits         8696     8697       +1     
- Misses        782      785       +3     
  Partials      467      467              
Impacted Files Coverage Δ
vyper/codegen/core.py 84.12% <100.00%> (ø)
vyper/ir/compile_ir.py 94.70% <100.00%> (+<0.01%) ⬆️
vyper/ir/optimizer.py 80.35% <0.00%> (-2.98%) ⬇️
vyper/semantics/validation/local.py 90.76% <0.00%> (ø)
vyper/builtin_functions/functions.py 90.76% <0.00%> (+0.02%) ⬆️
vyper/semantics/validation/annotation.py 91.94% <0.00%> (+1.34%) ⬆️

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 51bc1c2...eb6c9e9. Read the comment docs.

@@ -876,7 +877,8 @@ def zero_pad(bytez_placeholder):
# the actual value of X as a byte sequence,
# followed by the *minimum* number of zero-bytes
# such that len(enc(X)) is a multiple of 32.
num_zero_bytes = ["sub", ["ceil32", "len"], "len"]
# optimized form of ceil32(len) - len:
num_zero_bytes = ["and", 31, ["sub", 0, "len"]]
Copy link
Contributor

Choose a reason for hiding this comment

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

So cool !!!!

Copy link
Contributor

@skellet0r skellet0r left a comment

Choose a reason for hiding this comment

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

🚀

@charles-cooper charles-cooper merged commit c8ff0dd into vyperlang:master Apr 13, 2022
@charles-cooper charles-cooper deleted the optimize_ceil32 branch April 13, 2022 21:15
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.

4 participants