Skip to content

Conversation

@blishko
Copy link
Collaborator

@blishko blishko commented Sep 19, 2025

Description

When we have concrete size and destination index, we can determine that reading past the slice is just reading from the destination directly.

Source and source offset can still be symbolic.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

When we have concrete size and destination index, we can determine that
reading past the slice is just reading from the destination directly.

Source and source offset can still be symbolic.
Copy link
Collaborator

@msooseth msooseth left a comment

Choose a reason for hiding this comment

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

Nice catch, actually! Thanks :)

readWord i@(Lit x) (CopySlice _ (Lit dstOffset) _ _ dst) | dstOffset >= x+32 =
readWord i dst
readWord i@(Lit x) (CopySlice _ (Lit dstOffset) _ _ dst) | dstOffset >= x+32 = readWord i dst
readWord i@(Lit x) (CopySlice _ (Lit dstOffset) (Lit size) _ dst) | x >= dstOffset + size = readWord i dst
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's say we read Word (i.e. 32 bytes) starting at byte 10. So x=10. There's a CopySlice with dstoffset 8 and size 2. So it will write to bytes 8 and 9. Therefore from byte 10 we can read.

So this is correct :)

@msooseth msooseth merged commit 95b5e07 into main Sep 29, 2025
7 checks passed
@msooseth msooseth deleted the read-over-copy-slice-simpl branch September 29, 2025 16:32
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