Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Unified Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 2473923003: [turbofan][x64] Improve code generation for Float64LessThan with Float64Abs. (Closed)
Patch Set: Fix for realz. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/effect-control-linearizer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/x64/instruction-selector-x64.cc
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc
index a677733751252a2ddad807e1ec6273aa6618c00a..878e778da068c3563b1d06d7446c2411cf82fe28 100644
--- a/src/compiler/x64/instruction-selector-x64.cc
+++ b/src/compiler/x64/instruction-selector-x64.cc
@@ -1942,9 +1942,26 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user,
case IrOpcode::kFloat64Equal:
cont->OverwriteAndNegateIfEqual(kUnorderedEqual);
return VisitFloat64Compare(selector, value, cont);
- case IrOpcode::kFloat64LessThan:
+ case IrOpcode::kFloat64LessThan: {
+ Float64BinopMatcher m(value);
+ if (m.left().Is(0.0) && m.right().IsFloat64Abs()) {
+ // This matches the pattern
+ //
+ // Float64LessThan(#0.0, Float64Abs(x))
+ //
+ // which TurboFan generates for NumberToBoolean in the general case,
+ // and which evaluates to false if x is 0, -0 or NaN. We can compile
+ // this to a simple (v)ucomisd using not_equal flags condition, which
+ // avoids the costly Float64Abs.
+ cont->OverwriteAndNegateIfEqual(kNotEqual);
+ InstructionCode const opcode =
+ selector->IsSupported(AVX) ? kAVXFloat64Cmp : kSSEFloat64Cmp;
+ return VisitCompare(selector, opcode, m.left().node(),
+ m.right().InputAt(0), cont, false);
+ }
cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThan);
return VisitFloat64Compare(selector, value, cont);
+ }
case IrOpcode::kFloat64LessThanOrEqual:
cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual);
return VisitFloat64Compare(selector, value, cont);
@@ -2205,14 +2222,28 @@ void InstructionSelector::VisitFloat64Equal(Node* node) {
VisitFloat64Compare(this, node, &cont);
}
-
void InstructionSelector::VisitFloat64LessThan(Node* node) {
+ Float64BinopMatcher m(node);
+ if (m.left().Is(0.0) && m.right().IsFloat64Abs()) {
+ // This matches the pattern
+ //
+ // Float64LessThan(#0.0, Float64Abs(x))
+ //
+ // which TurboFan generates for NumberToBoolean in the general case,
+ // and which evaluates to false if x is 0, -0 or NaN. We can compile
+ // this to a simple (v)ucomisd using not_equal flags condition, which
+ // avoids the costly Float64Abs.
+ FlagsContinuation cont = FlagsContinuation::ForSet(kNotEqual, node);
+ InstructionCode const opcode =
+ IsSupported(AVX) ? kAVXFloat64Cmp : kSSEFloat64Cmp;
+ return VisitCompare(this, opcode, m.left().node(), m.right().InputAt(0),
+ &cont, false);
+ }
FlagsContinuation cont =
FlagsContinuation::ForSet(kUnsignedGreaterThan, node);
VisitFloat64Compare(this, node, &cont);
}
-
void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
FlagsContinuation cont =
FlagsContinuation::ForSet(kUnsignedGreaterThanOrEqual, node);
« no previous file with comments | « src/compiler/effect-control-linearizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698