Commit 3865493a authored by michael_dawson's avatar michael_dawson Committed by Commit bot

PPC: Match -0 - x with sign bit flip.

Optimiation similar to what is done for x86

R=mbrandy@us.ibm.com

BUG=

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

Cr-Commit-Position: refs/heads/master@{#27718}
parent 96ef78aa
...@@ -909,6 +909,13 @@ void InstructionSelector::VisitFloat64Add(Node* node) { ...@@ -909,6 +909,13 @@ void InstructionSelector::VisitFloat64Add(Node* node) {
void InstructionSelector::VisitFloat32Sub(Node* node) { void InstructionSelector::VisitFloat32Sub(Node* node) {
PPCOperandGenerator g(this);
Float32BinopMatcher m(node);
if (m.left().IsMinusZero()) {
Emit(kPPC_NegDouble, g.DefineAsRegister(node),
g.UseRegister(m.right().node()));
return;
}
VisitRRR(this, kPPC_SubDouble, node); VisitRRR(this, kPPC_SubDouble, node);
} }
...@@ -917,18 +924,23 @@ void InstructionSelector::VisitFloat64Sub(Node* node) { ...@@ -917,18 +924,23 @@ void InstructionSelector::VisitFloat64Sub(Node* node) {
// TODO(mbrandy): detect multiply-subtract // TODO(mbrandy): detect multiply-subtract
PPCOperandGenerator g(this); PPCOperandGenerator 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));
// -floor(-x) = ceil(x) if (mright0.left().IsMinusZero()) {
Emit(kPPC_CeilDouble, g.DefineAsRegister(node), // -floor(-x) = ceil(x)
g.UseRegister(mright0.right().node())); Emit(kPPC_CeilDouble, g.DefineAsRegister(node),
return; g.UseRegister(mright0.right().node()));
return;
}
} }
} }
Emit(kPPC_NegDouble, g.DefineAsRegister(node),
g.UseRegister(m.right().node()));
return;
} }
VisitRRR(this, kPPC_SubDouble, node); VisitRRR(this, kPPC_SubDouble, node);
} }
......
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