You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the WASM v128.load/v128.store intrinsics take a *v128 pointer as its argument, which means they will always assume that the pointer points to a 16 byte boundary.
This isn't always necessarily the case, e.g., when loading 4 f32s from a slice of memory into a v128. Right now, the only way to correctly perform this load, is to first load those 4 f32s into storage aligned to a v128, and then load that into a v128.
The WASM v128.load/v128.store intrincs do, however, support unaligned loads and stores, and for these to be efficient, the alignment hint in memargs needs to be correct. That is, we have to perform the loads with the correct types.
We could add load/store instruction variants for all vector element types, or add two generic load / stores that use the right types instead. E.g.
// Loads from an address aligned to T (otherwise UB)fnv128_load<T>(m:*constT) -> v128{ifalign_of::<T>() >= align_of::<v128>(){
ptr::read(m as*constv128)}else{
ptr::read_unaligned(m as*constv128)}}
This would work with *const f32 and also *const [f32; 4].
The text was updated successfully, but these errors were encountered:
I think this can be closed in favor of rust-lang/rust#74372 (comment). Right now I believe the intrinsic emit alignment hints but usage of ptr::read_unaligned will do what's necessary to get an unaligned load/store.
Currently, the WASM
v128.load
/v128.store
intrinsics take a*v128
pointer as its argument, which means they will always assume that the pointer points to a 16 byte boundary.This isn't always necessarily the case, e.g., when loading 4
f32
s from a slice of memory into av128
. Right now, the only way to correctly perform this load, is to first load those 4 f32s into storage aligned to a v128, and then load that into a v128.The WASM
v128.load
/v128.store
intrincs do, however, support unaligned loads and stores, and for these to be efficient, the alignment hint inmemargs
needs to be correct. That is, we have to perform the loads with the correct types.We could add
load
/store
instruction variants for all vector element types, or add two generic load / stores that use the right types instead. E.g.This would work with
*const f32
and also*const [f32; 4]
.The text was updated successfully, but these errors were encountered: