Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 3191199271613443a6dfe3ebdff826e22c28da5c..b3f8a430fd50f6e02151e69c14b0b558f1a9acf2 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -3074,10 +3074,10 @@ void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg, |
cvtsd2si(result_reg, input_reg); |
testl(result_reg, Immediate(0xFFFFFF00)); |
j(zero, &done, Label::kNear); |
- cmpl(result_reg, Immediate(0x80000000)); |
- j(equal, &conv_failure, Label::kNear); |
+ cmpl(result_reg, Immediate(1)); |
+ j(overflow, &conv_failure, Label::kNear); |
movl(result_reg, Immediate(0)); |
- setcc(above, result_reg); |
+ setcc(sign, result_reg); |
subl(result_reg, Immediate(1)); |
andl(result_reg, Immediate(255)); |
jmp(&done, Label::kNear); |
@@ -3114,9 +3114,8 @@ void MacroAssembler::TruncateHeapNumberToI(Register result_reg, |
Label done; |
movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
cvttsd2siq(result_reg, xmm0); |
- Set(kScratchRegister, V8_UINT64_C(0x8000000000000000)); |
- cmpq(result_reg, kScratchRegister); |
- j(not_equal, &done, Label::kNear); |
+ cmpq(result_reg, Immediate(1)); |
+ j(no_overflow, &done, Label::kNear); |
// Slow case. |
if (input_reg.is(result_reg)) { |
@@ -3136,9 +3135,8 @@ void MacroAssembler::TruncateDoubleToI(Register result_reg, |
XMMRegister input_reg) { |
Label done; |
cvttsd2siq(result_reg, input_reg); |
- movq(kScratchRegister, V8_INT64_C(0x8000000000000000)); |
- cmpq(result_reg, kScratchRegister); |
- j(not_equal, &done, Label::kNear); |
+ cmpq(result_reg, Immediate(1)); |
+ j(no_overflow, &done, Label::kNear); |
subq(rsp, Immediate(kDoubleSize)); |
movsd(MemOperand(rsp, 0), input_reg); |