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

Array copy optimization #1487

merged 1 commit into from Jun 25, 2019


Copy link

charles-cooper commented Jun 19, 2019

What I did

Optimize compiler-generated array copies. Depends on #1479 because of a conflict

How I did it

Remove bounds checks for when a loop is compiler-generated.

How to verify it

Check before/after IR for this contract

BIG_VALUE: constant(uint256) = 100

def do_work(a: uint256[BIG_VALUE]):
    assert self != msg.sender

def do_something(a: uint256[BIG_VALUE]):

Description for the changelog

Optimize compiler-generated array copies

Cute Animal Picture

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


This comment has been minimized.

Copy link

jacqueswww commented Jun 21, 2019

@charles-cooper I am not sure the description matches the code?
ie. where is the array copy optimisation?

@charles-cooper charles-cooper force-pushed the charles-cooper:array_copy_optimization branch from 17723a6 to c8cea1b Jun 21, 2019

This comment has been minimized.

Copy link
Collaborator Author

charles-cooper commented Jun 21, 2019

@jacqueswww I force pushed so the diff is cleaner now. The array bounds check is elided in the make_setter loop now, so instead of

for (i = 0; i < len; i++) {
  dst[uclamplt(i, len)] = src[uclamplt(i, len)]

it is now effectively

for (i = 0; i < len; i++) {
  dst[i] = src[i]
@charles-cooper charles-cooper changed the title WIP: Array copy optimization Array copy optimization Jun 21, 2019
@jacqueswww jacqueswww merged commit b7f9750 into vyperlang:master Jun 25, 2019
3 checks passed
3 checks passed
ci/circleci: lint Your tests passed on CircleCI!
ci/circleci: py36-core Your tests passed on CircleCI!
ci/circleci: py37-core Your tests passed on CircleCI!
@charles-cooper charles-cooper deleted the charles-cooper:array_copy_optimization branch Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.