Bug 1656229 - replace a computation by a constant load. r=jseward
authorLars T Hansen <lhansen@mozilla.com>
Thu, 20 Aug 2020 14:43:04 +0000
changeset 610153 3da7d219a9e4e4f6e23892e2ef27192de1954f9d
parent 610152 a475ddc1aeec7006fab0c9d28660e6c90a8c6d2e
child 610154 da2ca8466508070950b870a6906a595e690abdd3
push id13553
push userffxbld-merge
push dateMon, 24 Aug 2020 12:51:36 +0000
treeherdermozilla-beta@a54f8b5d0977 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjseward
bugs1656229
milestone81.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1656229 - replace a computation by a constant load. r=jseward This is technical debt from the initial SIMD work - it's faster to load a constant here than to compute it. Benchmark data not forthcoming, but elsewhere i've found that we break even at two instructions and it's better to load the value than to compute it in three. Differential Revision: https://phabricator.services.mozilla.com/D87306
js/src/jit/x86-shared/MacroAssembler-x86-shared-SIMD.cpp
--- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-SIMD.cpp
+++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-SIMD.cpp
@@ -2011,22 +2011,20 @@ void MacroAssemblerX86Shared::unsignedTr
   // The cvttps2dq instruction is the workhorse but does not handle NaN or out
   // of range values as we need it to.  We want to saturate too-large positive
   // values to FFFFFFFFh and negative values to zero.  NaN and -0 become 0.
 
   // Convert NaN and negative values to zeroes in dest.
   vpxor(Operand(scratch), scratch, scratch);
   vmaxps(Operand(scratch), dest, dest);
 
-  // Compute the float value of 0x7FFFFFFF (the largest positive signed integer
-  // value) in all lanes in scratch.  We use it to bias the conversion to handle
-  // edge cases.
-  vpcmpeqd(Operand(scratch), scratch, scratch);
-  vpsrld(Imm32(1), scratch, scratch);
-  vcvtdq2ps(scratch, scratch);
+  // Place the largest positive signed integer in all lanes in scratch.
+  // We use it to bias the conversion to handle edge cases.
+  asMasm().loadConstantSimd128Float(SimdConstant::SplatX4(2147483647.f),
+                                    scratch);
 
   // temp = dest - 7FFFFFFFh (as floating), this brings integers in the unsigned
   // range but above the signed range into the signed range; 0 => -7FFFFFFFh.
   vmovaps(dest, temp);
   vsubps(Operand(scratch), temp, temp);
 
   // scratch = mask of biased values that are greater than 7FFFFFFFh.
   vcmpleps(Operand(temp), scratch);