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,19 +1928,28 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
#endif
i.OutputRegister(0), kScratchDoubleReg);
#if V8_TARGET_ARCH_PPC64
if (check_conversion) {
// Set 2nd output to zero if conversion fails.
CRegister cr = cr7;
int crbit = v8::internal::Assembler::encode_crbit(
cr, static_cast<CRBit>(VXCVI % CRWIDTH));
__ mcrfs(cr, VXCVI); // extract FPSCR field containing VXCVI into cr7
// Handle conversion failures (such as overflow).
if (CpuFeatures::IsSupported(ISELECT)) {
if (check_conversion) {
__ 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 {
if (check_conversion) {
__ li(i.OutputRegister(1), Operand::Zero());
__ 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
......
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