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

Force aligned access for EVM stack #1050

Open
chfast opened this issue Oct 10, 2024 · 2 comments
Open

Force aligned access for EVM stack #1050

chfast opened this issue Oct 10, 2024 · 2 comments

Comments

@chfast
Copy link
Member

chfast commented Oct 10, 2024

Compilers generate vector instructions with unaligned access to access elements on the EVM stack. Inform compiler that the stack memory is 32-byte aligned.

@Raneet10
Copy link

Would that mean hinting something like:

    #ifdef __MSC_VER
        StackTop* st = static_cast<StackTop*>(__builtin_assume_aligned(&state.stack, 256));
    #else
        StackTop* st = std::assume_aligned<256>(&state.stack);
    #endif
    CoreFn(*st);
    state.adjust_stack_size(instr::traits[Op].stack_height_change);

?

I'm not sure whether there's a quick way to check on goldbolt or something.

@chfast
Copy link
Member Author

chfast commented Jan 20, 2025

You can solely rely on standard std::assume_aligned. But I was thinking if this can be done more elegantly by annotating the type with alignas.

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

No branches or pull requests

3 participants
@chfast @Raneet10 and others