https://codereview.chromium.org/222403002/diff/1/src/arm/macro-assembler-arm.cc
File src/arm/macro-assembler-arm.cc (left):

https://codereview.chromium.org/222403002/diff/1/src/arm/macro-assembler-arm.cc#oldcode3819
src/arm/macro-assembler-arm.cc:3819: // Set rounding mode to round to
the nearest integer by clearing bits[23:22].
Shouldn't we be in the right rounding mode already? ECMAScript maths
operations are supposed to be done in round-to-nearest mode, and this is
also the default FPSCR setting. If we've changed it explicitly somewhere
else (for whatever reason), we're probably not doing normal ECMAScript
maths properly.

If I'm correct about that, the whole thing collapses down:

// Handle inputs >= 255 (including +infinity).
mov(result_reg, 255);
Vmov(double_scratch, 255.0, result_reg);
VFPCompareAndSetFlags(input_reg, double_scratch);
b(ge, &done);

// All other inputs will clamp to the range [0-255]: NaN and -infinity
both produce 0.
vcvt_u32_f64(double_scratch.low(), input_reg, kFPSCRRounding);
Vmov(result_reg, double_scratch.low());

This is more-or-less equivalent to what we did in ClampDoubleToUint8 in
src/arm64/macro-assembler-arm64.cc, though the available instructions
make it much simpler in A64.

https://codereview.chromium.org/222403002/diff/1/src/arm/macro-assembler-arm.cc
File src/arm/macro-assembler-arm.cc (right):

https://codereview.chromium.org/222403002/diff/1/src/arm/macro-assembler-arm.cc#newcode3800
src/arm/macro-assembler-arm.cc:3800: b(le, &done);  // Double value is
<= 0, NaN or Inf, return 0.
Actually there are only two input ranges where vcvt.u32 doesn't agree
with this clamp operation:

 - Values greater than 255 (since vcvt only converts to (u)int32 values.
 - +infinity, where vcvt produces 0 but we want 255.

We can catch both of these ranges with the >=255 test, so the <=0 test
can be omitted entirely.

(The old implementation used vcvt.s32 so the zero check was necessary
there.)

https://codereview.chromium.org/222403002/

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to