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

Change sponge_absorb_mem to be used in combination with recurse_or_return? #303

Open
Sword-Smith opened this issue Jun 17, 2024 · 0 comments
Labels
⏩ speedup Makes stuff go faster.

Comments

@Sword-Smith
Copy link
Collaborator

Sword-Smith commented Jun 17, 2024

Cf. #302 instructions that mutate a pointer value should, if possible, read the pointer value from ST[5] or ST[6].

I think it should be possible to replace the loop-condition here if sponge_absorb_mem had five dummy-stack values instead of four and it mutated ST[5] instead of ST[0] as it does now.

            // BEFORE:    _ *remainder 0 0 0 0 *bfe_sequence
            // INVARIANT: _ *remainder a b c d *bfe_sequence'
            // AFTER:     _ *remainder e f g h *remainder
            {hash_all_full_chunks}:
                dup 5 dup 1 eq
                skiz return

                // _ *remainder a b c d *bfe_sequence
                sponge_absorb_mem

                // _ *remainder e f g h *bfe_sequence'
                recurse

With this change the code could be reduced to

            // BEFORE:    _ *remainder *bfe_sequence 0 0 0 0 0
            // INVARIANT: _ *remainder *bfe_sequence' a b c d e
            // AFTER:     _ *remainder *remainder f g h i j
            {hash_all_full_chunks}:
                sponge_absorb_mem
                recurse_or_return
@Sword-Smith Sword-Smith added the ⏩ speedup Makes stuff go faster. label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏩ speedup Makes stuff go faster.
Projects
None yet
Development

No branches or pull requests

1 participant