Skip to content

wasm2c: Extend segue to simd and unshared atomics - #2803

Merged
shravanrn merged 1 commit into
WebAssembly:mainfrom
UT-Security:segue-simd-atomics
Aug 1, 2026
Merged

wasm2c: Extend segue to simd and unshared atomics#2803
shravanrn merged 1 commit into
WebAssembly:mainfrom
UT-Security:segue-simd-atomics

Conversation

@shravanrn

@shravanrn shravanrn commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

This is part 1 of the wasm2c performance optimization round I am conducting. Second part is here

This part, part 1, is just minor cleanup of segue --- the major performance optimization will come in part 2.

This PR extends the use of segment registers to simd and unshared atomics. The initial implementation of segue didn't cover simd because simd everywhere didn't support taking pointers to the gs segment. However, it turns out there is an easy way to solve it --- all we need are wrappers that copy to a local variable first and then pass that to simde. The optimizations in clang are able to eliminate all the extra memcpy operations and the result is what we'd want.

@sbc100

sbc100 commented Aug 1, 2026

Copy link
Copy Markdown
Member

Can you explain what all the MEM_ADDR -> MEM_ADDR_MEMOP changes are for?

@shravanrn

Copy link
Copy Markdown
Collaborator Author

Can you explain what all the MEM_ADDR -> MEM_ADDR_MEMOP changes are for?

@sbc100 MEM_ADDR_MEMOP is a macro that uses segments to access memory if this feature is enabled, and falls back to using instance parameter's memory field to access memory otherwise. MEM_ADDR is the macro that unconditionally uses the instance parameter's memory field to access memory.

Right now using segments was only allowed in the scalar loads/stores, but there is no reason to restrict this as the hardware supports segments on Simd operations as well. So this change ensures simd operations can use segments as well.

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the reminder.

@shravanrn
shravanrn merged commit ec6f497 into WebAssembly:main Aug 1, 2026
17 checks passed
@shravanrn
shravanrn deleted the segue-simd-atomics branch August 1, 2026 18: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.

2 participants