Closed Bug 996076 Opened 10 years ago Closed 10 years ago

SIMD: Implement more int32x4 and float32x4 functions present in the polyfill

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: bbouvier, Assigned: bbouvier)

Details

Attachments

(4 files)

(In reply to Soeren.Balko from bug 992267 comment #1)
> Great to see progress on that end! The current SIMD implementation in
> Nightly is IMHO fairly restrictive in its int32x4 implementation.
> Specifically, int32x4 does neither provide for a min, lessThan, or abs
> function. lessThan, greaterThan, etc. are present in the polyfill
> (https://github.com/johnmccutchan/ecmascript_simd), but are missing from the
> Firefox implementation. Any chance to have it added? 
> 
> Without these functions, comparing two int32x4 vectors becomes unnecessary
> difficult and comes down to subtracting them, reading out the signMask from
> the result vector, and bit-shifting that signMask to get the comparisons for
> the individual lanes. The latter operation is obviously sequential,
> negatively affecting performance.

Thanks for reporting that! Indeed these functions seem to be missing when comparing to the polyfill [1] which stands as a reference.

Note that int32x4.min and int32x4.abs you're mentioning aren't present in the polyfill either, although float32x4.min and float32x4.abs are there.

There is a SSE instruction (PMIN{U,S}{B,D,W} -- some variants are available after SSE4.1) for int32x4.min so it would be reasonable to add it too, if the equivalent ARM instruction exists or can be easily emulated. Same holds for int32x4.max, greaterThan (can't see an instruction for lessThan, so we'd have to emulate it with greaterThan and another operation), equality, absolute value (SSE3).

I'll add them unless somebody beats me to it.

[1] https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js
This preparatory patch does the following things:
- a few style cleanups for some if and for loops
- s/uint32_t/unsigned for loop iterators
- hoist error handling code, so as to remove parenthesis
Assignee: nobody → benj
Status: NEW → ASSIGNED
Attachment #8415682 - Flags: review?(nmatsakis)
Float32x4 bitwise operators need to interpret the float32 datum as int32, so we need to convert them. Everything is the same as in Func otherwise, so let's just generalize Func a little bit.
Attachment #8415686 - Flags: review?(nmatsakis)
With these patches, we are now at the same level as the polyfill implementation.
Niko, should we plan on adding also min, max, abs and maybe some other functions for int32x4?
Summary: SIMD: Implement more int32x4 functions → SIMD: Implement more int32x4 and float32x4 functions present in the polyfill
Attachment #8415682 - Flags: review?(nmatsakis) → review+
Attachment #8415683 - Flags: review?(nmatsakis) → review+
Attachment #8415686 - Flags: review?(nmatsakis) → review+
Attachment #8415688 - Flags: review?(nmatsakis) → review+
You need to log in before you can comment on or make changes to this bug.