SIMD float64x2 comparisons are broken.

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
3 years ago
2 years ago

People

(Reporter: Jukka Jylänki, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(firefox41 affected)

Details

Attachments

(1 attachment)

520 bytes, application/x-javascript
Details
(Reporter)

Description

3 years ago
Created attachment 8624884 [details]
aa.js

STR:

1. Run the attached file in SpiderMonkey.

Observed: The file prints

a: x=-3.4028234663852886e+38, y=-2.5
b: x=-Infinity, y=1.401298464e-45
c: x=-1, y=-1
A: x=-3.4028234663852886e+38, y=-2.5
B: x=-Infinity, y=1.401298464324817e-45
C: x=-1, y=0

Expected: The file should print

a: x=-3.4028234663852886e+38, y=-2.5
b: x=-Infinity, y=1.401298464e-45
c: x=-1, y=0
A: x=-3.4028234663852886e+38, y=-2.5
B: x=-Infinity, y=1.401298464324817e-45
C: x=-1, y=0

The test case was written for SIMD.float64x2.greaterThan(), but changing the comparison e.g. to SIMD.float64x2.lessThan(), a similar issue occurs, so other comparison functions may be affected here.
Flags: needinfo?(benj)
This happens because we haven't updated our SIMD implementation to use the BoolX2 vector. In the former spec, this is correct with c being an int32x4: the result of comparing a.x and b.x (resp. a.y and b.y) would be copied in both c.x and c.y (resp. c.z and c.w).
I'll add the new Bool types.
Depends on: 1160971
Flags: needinfo?(benj)
The current patches in Bug 1160971 add a Bool64x2 type which is used as the result of the Float64x2 comparison functions.
Fixed by bug 1160971:



var f64 = SIMD.Float64x2;
var f32 = SIMD.Float32x4;

function p64(s, n) {
    console.log(n + ': x=' + f64.extractLane(s, 0) + ', y=' + f64.extractLane(s, 1));
}
function p32(s, n) {
    console.log(n + ': x=' + f32.extractLane(s, 0) + ', y=' + f32.extractLane(s, 1));
}

var a = SIMD.Float64x2(-3.4028234663852886e+38,-2.5)
p64(a, 'a');
var b = SIMD.Float64x2(-Infinity,1.4012984639999999e-45)
p64(b, 'b');
var c = SIMD.Float64x2.greaterThan(a, b);
console.log('c: x=' + SIMD.Bool64x2.extractLane(c, 0) + ', y=' + SIMD.Bool64x2.extractLane(c, 1));

var a = SIMD.Float32x4(-3.4028234663852886e+38,-2.5)
p32(a, 'A');
var b = SIMD.Float32x4(-Infinity,1.4012984639999999e-45)
p32(b, 'B');
var c = SIMD.Float32x4.greaterThan(a, b);
console.log('C: x=' + SIMD.Bool32x4.extractLane(c, 0) + ', y=' + SIMD.Bool32x4.extractLane(c, 1));



// Output:
a: x=-3.4028234663852886e+38, y=-2.5
b: x=-Infinity, y=1.401298464e-45
c: x=true, y=false
A: x=-3.4028234663852886e+38, y=-2.5
B: x=-Infinity, y=1.401298464324817e-45
C: x=true, y=false
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.