Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Add opcodes for converting between integer vectors of different lane size. #21

Closed
billbudge opened this issue May 25, 2017 · 2 comments · Fixed by #89
Closed

Add opcodes for converting between integer vectors of different lane size. #21

billbudge opened this issue May 25, 2017 · 2 comments · Fixed by #89

Comments

@billbudge
Copy link

billbudge commented May 25, 2017

Integer conversions are useful when data is stored in a small integer format, but calculations are performed at a higher precision. They allow data to be unpacked and packed. Synthesizing these with opcodes in the spec is awkward. They are well supported on all architectures.

Widening conversions, with signed or unsigned saturation. These are unary operations, converting low or high half of the smaller lane vector in order to avoid multiple return values.

i32x4.SConvertI16x8Low(x: v128) -> v128
i32x4.SConvertI16x8High(x: v128) -> v128
i32x4.UConvertI16x8Low(x: v128) -> v128
i32x4.UConvertI16x8High(x: v128) -> v128

i16x8.SConvert8x16Low(x: v128) -> v128
i16x8.SConvert8x16High(x: v128) -> v128
i16x8.UConvert8x16Low(x: v128) -> v128
i16x8.UConvert8x16High(x: v128) -> v128

Narrowing conversions, signed and unsigned. These are binary operations, converting two input vectors into a single smaller lane vector.

i16x8.SConvertI32x4(x: v128, y:v128) -> v128
i16x8.UConvertI32x4(x: v128, y:v128) -> v128

i8x16.SConvertI16x8(x: v128, y:v128) -> v128
i8x16.UConvertI16x8(x: v128, y:v128) -> v128

@stoklund
Copy link
Contributor

I think you swapped "narrowing" and "widening".

The widening conversions could be implemented as a swizzle and a right shift. I don't think we want to depend on implementations recognizing that pattern, though.

@billbudge
Copy link
Author

Fixed that. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants