Commit fe744122 authored by baptiste.afsa's avatar baptiste.afsa Committed by Commit bot

[turbofan][arm64] Match fneg for -0.0 - x pattern.

Note that this patch add an extra bit to the ArchOpcodeField.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1013743006

Cr-Commit-Position: refs/heads/master@{#27494}
parent c293448f
...@@ -689,6 +689,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -689,6 +689,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
0, 2); 0, 2);
break; break;
} }
case kArm64Float64Neg:
__ Fneg(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
break;
case kArm64Float64Sqrt: case kArm64Float64Sqrt:
__ Fsqrt(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); __ Fsqrt(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
break; break;
......
...@@ -85,6 +85,7 @@ namespace compiler { ...@@ -85,6 +85,7 @@ namespace compiler {
V(Arm64Float64Mul) \ V(Arm64Float64Mul) \
V(Arm64Float64Div) \ V(Arm64Float64Div) \
V(Arm64Float64Mod) \ V(Arm64Float64Mod) \
V(Arm64Float64Neg) \
V(Arm64Float64Sqrt) \ V(Arm64Float64Sqrt) \
V(Arm64Float64RoundDown) \ V(Arm64Float64RoundDown) \
V(Arm64Float64RoundTiesAway) \ V(Arm64Float64RoundTiesAway) \
......
...@@ -1069,17 +1069,22 @@ void InstructionSelector::VisitFloat64Add(Node* node) { ...@@ -1069,17 +1069,22 @@ void InstructionSelector::VisitFloat64Add(Node* node) {
void InstructionSelector::VisitFloat64Sub(Node* node) { void InstructionSelector::VisitFloat64Sub(Node* node) {
Arm64OperandGenerator g(this); Arm64OperandGenerator g(this);
Float64BinopMatcher m(node); Float64BinopMatcher m(node);
if (m.left().IsMinusZero() && m.right().IsFloat64RoundDown() && if (m.left().IsMinusZero()) {
CanCover(m.node(), m.right().node())) { if (m.right().IsFloat64RoundDown() &&
if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub && CanCover(m.node(), m.right().node())) {
CanCover(m.right().node(), m.right().InputAt(0))) { if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub &&
Float64BinopMatcher mright0(m.right().InputAt(0)); CanCover(m.right().node(), m.right().InputAt(0))) {
if (mright0.left().IsMinusZero()) { Float64BinopMatcher mright0(m.right().InputAt(0));
Emit(kArm64Float64RoundUp, g.DefineAsRegister(node), if (mright0.left().IsMinusZero()) {
g.UseRegister(mright0.right().node())); Emit(kArm64Float64RoundUp, g.DefineAsRegister(node),
return; g.UseRegister(mright0.right().node()));
return;
}
} }
} }
Emit(kArm64Float64Neg, g.DefineAsRegister(node),
g.UseRegister(m.right().node()));
return;
} }
VisitRRRFloat64(this, kArm64Float64Sub, node); VisitRRRFloat64(this, kArm64Float64Sub, node);
} }
......
...@@ -127,11 +127,11 @@ typedef int32_t InstructionCode; ...@@ -127,11 +127,11 @@ typedef int32_t InstructionCode;
// for code generation. We encode the instruction, addressing mode, and flags // for code generation. We encode the instruction, addressing mode, and flags
// continuation into a single InstructionCode which is stored as part of // continuation into a single InstructionCode which is stored as part of
// the instruction. // the instruction.
typedef BitField<ArchOpcode, 0, 7> ArchOpcodeField; typedef BitField<ArchOpcode, 0, 8> ArchOpcodeField;
typedef BitField<AddressingMode, 7, 5> AddressingModeField; typedef BitField<AddressingMode, 8, 5> AddressingModeField;
typedef BitField<FlagsMode, 12, 2> FlagsModeField; typedef BitField<FlagsMode, 13, 2> FlagsModeField;
typedef BitField<FlagsCondition, 14, 4> FlagsConditionField; typedef BitField<FlagsCondition, 15, 4> FlagsConditionField;
typedef BitField<int, 14, 18> MiscField; typedef BitField<int, 19, 13> MiscField;
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
......
...@@ -2257,6 +2257,21 @@ TEST_F(InstructionSelectorTest, Word32Clz) { ...@@ -2257,6 +2257,21 @@ TEST_F(InstructionSelectorTest, Word32Clz) {
EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
} }
TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) {
StreamBuilder m(this, kMachFloat64, kMachFloat64);
Node* const p0 = m.Parameter(0);
Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0);
m.Return(n);
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode());
ASSERT_EQ(1U, s[0]->InputCount());
EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
ASSERT_EQ(1U, s[0]->OutputCount());
EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
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