Closed Bug 1313512 Opened 8 years ago Closed 6 years ago

SIMD: Implement (un)signed conversions between integer x4 types

Categories

(Core :: JavaScript Engine, defect, P5)

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: jujjyl, Unassigned)

References

Details

Attempting to import SIMD.Int32x4.fromUint32x4() function to asm.js, with

  var SIMD_Int32x4=global.SIMD.Int32x4;
  var SIMD_Int32x4_fromUint32x4=SIMD_Int32x4.fromUint32x4;

I'm getting an error

  TypeError: asm.js type error: 'fromUint32x4' is not an operation supported by the SIMD type

STR: http://clb.demon.fi/bugs/int32x4_from_uint32x4/test_simd_int32x4.html
Further down in the file, lines

  var SIMD_Uint32x4=global.SIMD.Uint32x4;
  var SIMD_Uint32x4_fromInt32x4=SIMD_Uint32x4.fromInt32x4;  

are giving a similar error

  TypeError: asm.js type error: 'fromInt32x4' is not an operation supported by the SIMD type
Spidermonkey doesn't implement SIMD.Int32x4.fromUint32x4 or SIMD.Uint32x4.fromInt32x4; in general, these can be supplanted by the bit cast variants, since a number can be seen as signed or unsigned. I just found out these functions belong in the SIMD.js spec though, with the imprecise conversion rule: if a lane input can't fit the destination type, an error is raised.

Can you use SIMD.Int32x4.fromUint32x4Bits and SIMD.Uint32x4.fromInt32x4Bits instead? (these are type coercion no-op (i.e. no generated code) in asm.js). Or do you need the imprecise conversion rule to apply here?
Flags: needinfo?(jujjyl)
When compiling SSE code (the most important case), Emscripten is actually already using only the *Bits variants, but it was just importing all of the SIMD.js functions unconditionally, since we don't have an instruction level mechanism of tracking what needs to be imported in.

Removed these for now in Emscripten: https://github.com/kripken/emscripten/commit/4092210034fe79ecdff1b8f69744cf770bcecbc3 . The only scenario this would affect is if user codebases might be using the intrinsics explicitly via the emscripten/vector.h (https://github.com/kripken/emscripten/blob/master/system/include/emscripten/vector.h), but I don't think anyone currently is.
Flags: needinfo?(jujjyl)
OK, thanks! Retargeting the bug summary then. I think that if the specification mandates it, we *could* implement it, but it's likely to be low priority unless it's used in real world contexts or added in wasm. CC'ing other SIMD.js people in case they know more.
Blocks: 894105
Priority: -- → P5
Summary: asm.js type error: 'fromUint32x4' is not an operation supported by the SIMD type → SIMD: Implement (un)signed conversions between x4 types
Summary: SIMD: Implement (un)signed conversions between x4 types → SIMD: Implement (un)signed conversions between integer x4 types
It hasn't been requested for WebAssembly to my knowledge. A trapping int <-> uint conversion is pretty easy to implement efficiently using the existing SIMD.js primitives, so I don't see a big need for providing it.
SIMD.js is being removed (bug 1416723). (This could be added to wasm, but that's not the right forum to discuss it)
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.