Make conversion to/from arrays generic - #286
Conversation
…Move array element and other metadata from SimdBase to SimdArray. This unifies conversion to/from arrays between SIMD vectors and masks.
|
Looks nice in principle, but we should benchmark to make sure it doesn't cause regressions. It has happened before that changing how arrays are loaded/stored resulted in differences. |
|
I tried converting Vello to this and ended up disliking how this ends up getting used in practice. Being able to load and store masks and vectors without knowing which one it is just isn't very useful, but it makes the docs harder to navigate and requires changes to the existing user code in some cases ( I think the upsides of this can be achieved without requiring code changes from users, and without complicating and fragmenting the trait hierarchy. I'll experiment with that. |
|
Closing in favor of #292 |
Move conversion to/from array into a separate trait,
SimdArray. Unifies conversion handling between vectors and masks.SimdArrayRefwith in-place conversions to references is added as an extension for vectors only (not masks).In most cases
store_arrayno longer needs the length to be explicitly qualified; in the few places where it is needed, it can be done through the usual turbofish synatx, same asFromandTryFrom.This improves generic programming:
S::f32scan now be converted to/from arraysDespite
Nnow living inSimdArray, it is still accessible throughSimdBasethrough supertrait relationship.Pairs well with #285 which makes arrays more useful in general. Also conflicts with it, but c'est la vie, I'll resolve conflicts in one when the other lands.
This also drops 204 code-generated wrappers around various safe transmute functions, reducing the size of the generated code.