Commit ffaac6bb authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

PPC: set DoubleToInt64 overflow to zero

fctidz saturates the output in case of overflow. This cl
makes the behaviour similar to s390 and sets the output to zero.

Change-Id: Ic043625c46147eb02a65dfdbbcd883a067ba6981
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2527783Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#71061}
parent 89ca48c9
...@@ -1928,21 +1928,30 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1928,21 +1928,30 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
#endif #endif
i.OutputRegister(0), kScratchDoubleReg); i.OutputRegister(0), kScratchDoubleReg);
#if V8_TARGET_ARCH_PPC64 #if V8_TARGET_ARCH_PPC64
if (check_conversion) {
// Set 2nd output to zero if conversion fails.
CRegister cr = cr7; CRegister cr = cr7;
int crbit = v8::internal::Assembler::encode_crbit( int crbit = v8::internal::Assembler::encode_crbit(
cr, static_cast<CRBit>(VXCVI % CRWIDTH)); cr, static_cast<CRBit>(VXCVI % CRWIDTH));
__ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7 __ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7
// Handle conversion failures (such as overflow).
if (CpuFeatures::IsSupported(ISELECT)) { if (CpuFeatures::IsSupported(ISELECT)) {
__ li(i.OutputRegister(1), Operand(1)); if (check_conversion) {
__ isel(i.OutputRegister(1), r0, i.OutputRegister(1), crbit); __ li(i.OutputRegister(1), Operand(1));
__ isel(i.OutputRegister(1), r0, i.OutputRegister(1), crbit);
} else {
__ isel(i.OutputRegister(0), r0, i.OutputRegister(0), crbit);
}
} else { } else {
__ li(i.OutputRegister(1), Operand::Zero()); if (check_conversion) {
__ bc(v8::internal::kInstrSize * 2, BT, crbit); __ li(i.OutputRegister(1), Operand::Zero());
__ li(i.OutputRegister(1), Operand(1)); __ bc(v8::internal::kInstrSize * 2, BT, crbit);
__ li(i.OutputRegister(1), Operand(1));
} else {
__ mr(ip, i.OutputRegister(0));
__ li(i.OutputRegister(0), Operand::Zero());
__ bc(v8::internal::kInstrSize * 2, BT, crbit);
__ mr(i.OutputRegister(0), ip);
}
} }
}
#endif #endif
DCHECK_EQ(LeaveRC, i.OutputRCBit()); DCHECK_EQ(LeaveRC, i.OutputRCBit());
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment