Skip to content

Array copy optimization#1487

Merged
jacqueswww merged 1 commit into
vyperlang:masterfrom
charles-cooper:array_copy_optimization
Jun 25, 2019
Merged

Array copy optimization#1487
jacqueswww merged 1 commit into
vyperlang:masterfrom
charles-cooper:array_copy_optimization

Conversation

@charles-cooper

@charles-cooper charles-cooper commented Jun 19, 2019

Copy link
Copy Markdown
Member

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

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

@public
def do_something(a: uint256[BIG_VALUE]):
    self.do_work(a)

Description for the changelog

Optimize compiler-generated array copies

Cute Animal Picture

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

@jacqueswww

jacqueswww commented Jun 21, 2019

Copy link
Copy Markdown
Contributor

@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 array_copy_optimization branch from 17723a6 to c8cea1b Compare June 21, 2019 16:32
@charles-cooper

Copy link
Copy Markdown
Member Author

@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
@charles-cooper charles-cooper deleted the array_copy_optimization branch September 24, 2019 11:49
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