From 1ce92608c07fd2dea98ead9d441c8effc8a1af6c Mon Sep 17 00:00:00 2001 From: Eduardo Aguilar Date: Fri, 28 Aug 2020 12:47:45 +0200 Subject: [PATCH 4/4] ppc: CmpDouble: fix unordered comparison check If unordered, any comparison should be false except for not equal. Not equal gives problems in AssembleArchBranch, so leaving jumping to false as default for the unordered bit. Signed-off-by: Eduardo Aguilar --- .../backend/ppc/code-generator-ppc.cc | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/deps/v8/src/compiler/backend/ppc/code-generator-ppc.cc b/deps/v8/src/compiler/backend/ppc/code-generator-ppc.cc index b6b01e70..9697a405 100644 --- a/deps/v8/src/compiler/backend/ppc/code-generator-ppc.cc +++ b/deps/v8/src/compiler/backend/ppc/code-generator-ppc.cc @@ -2270,14 +2270,10 @@ void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { Condition cond = FlagsConditionToCondition(condition, op); if (op == kPPC_CmpDouble) { - // check for unordered if necessary - if (cond == le) { + // comparison against any NaN operand should go to false except on not + // equal, but this case seems to introduce problems, so jumping + // inconditionally to false in case of CR_FU. __ bunordered(flabel, cr); - // Unnecessary for eq/lt since only FU bit will be set. - } else if (cond == gt) { - __ bunordered(tlabel, cr); - // Unnecessary for ne/ge since only FU bit will be set. - } } __ b(cond, tlabel, cr); if (!branch->fallthru) __ b(flabel); // no fallthru to flabel. @@ -2363,13 +2359,10 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr, CRegister cr = cr0; Condition cond = FlagsConditionToCondition(condition, op); if (op == kPPC_CmpDouble) { - // check for unordered if necessary - if (cond == le) { + if (cond != ne) { __ bunordered(&end, cr); - // Unnecessary for eq/lt since only FU bit will be set. - } else if (cond == gt) { + } else { __ bunordered(tlabel, cr); - // Unnecessary for ne/ge since only FU bit will be set. } } __ b(cond, tlabel, cr); @@ -2393,11 +2386,11 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, Condition cond = FlagsConditionToCondition(condition, op); if (op == kPPC_CmpDouble) { // check for unordered if necessary - if (cond == le) { + if (cond != ne) { reg_value = 0; __ li(reg, Operand::Zero()); __ bunordered(&done, cr); - } else if (cond == gt) { + } else { reg_value = 1; __ li(reg, Operand(1)); __ bunordered(&done, cr); -- 2.20.1