diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index e0dbba38d85..2ff61409f67 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -508,7 +508,7 @@ struct RecApprox { }; template struct RecSqrtApprox { - static inline T apply(T x) { return sqrt(1 / x); } + static inline T apply(T x) { return 1 / sqrt(x); } }; template struct Sqrt { diff --git a/js/src/tests/ecma_7/SIMD/float32x4reciprocalsqrt.js b/js/src/tests/ecma_7/SIMD/float32x4reciprocalsqrt.js index 10c29a8c8a6..cf1f5e13c51 100644 --- a/js/src/tests/ecma_7/SIMD/float32x4reciprocalsqrt.js +++ b/js/src/tests/ecma_7/SIMD/float32x4reciprocalsqrt.js @@ -6,7 +6,7 @@ var int32x4 = SIMD.int32x4; var summary = 'float32x4 reciprocalSqrt'; function reciprocalsqrtf(a) { - return Math.fround(Math.sqrt(1 / Math.fround(a))); + return Math.fround(1 / Math.sqrt(a)); } function test() { diff --git a/js/src/tests/ecma_7/SIMD/float64x2-arithmetic.js b/js/src/tests/ecma_7/SIMD/float64x2-arithmetic.js index 0f7b6564bb6..d23f5cff909 100644 --- a/js/src/tests/ecma_7/SIMD/float64x2-arithmetic.js +++ b/js/src/tests/ecma_7/SIMD/float64x2-arithmetic.js @@ -15,7 +15,7 @@ function mul(a, b) { return a * b; } function div(a, b) { return a / b; } function neg(a) { return -a; } function reciprocalApproximation(a) { return 1 / a; } -function reciprocalSqrtApproximation(a) { return Math.sqrt(1 / a); } +function reciprocalSqrtApproximation(a) { return 1 / Math.sqrt(a); } function testAdd(v, w) { return testBinaryFunc(v, w, float64x2.add, add);