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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2309953002: [turbofan] Introduce dedicated NumberToBoolean operator. (Closed)
Patch Set: Fix unittest. Created 4 years, 3 months 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/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index 0bb8a1ce2585fb1454485f152a4536296773c770..6f4b15a71a8a303ce880eee5fad927cf446f9b97 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -2005,6 +2005,23 @@ class RepresentationSelector {
if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
return;
}
+ case IrOpcode::kNumberToBoolean: {
+ Type* const input_type = TypeOf(node->InputAt(0));
+ if (input_type->Is(Type::Integral32())) {
+ VisitUnop(node, UseInfo::TruncatingWord32(),
+ MachineRepresentation::kBit);
+ if (lower()) lowering->DoIntegral32ToBit(node);
+ } else if (input_type->Is(Type::OrderedNumber())) {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kBit);
+ if (lower()) lowering->DoOrderedNumberToBit(node);
+ } else {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kBit);
+ if (lower()) lowering->DoNumberToBit(node);
+ }
+ return;
+ }
case IrOpcode::kNumberToInt32: {
// Just change representation if necessary.
VisitUnop(node, UseInfo::TruncatingWord32(),
@@ -3187,6 +3204,34 @@ void SimplifiedLowering::DoStringToNumber(Node* node) {
NodeProperties::ChangeOp(node, common()->Call(desc));
}
+void SimplifiedLowering::DoIntegral32ToBit(Node* node) {
+ Node* const input = node->InputAt(0);
+ Node* const zero = jsgraph()->Int32Constant(0);
+ Operator const* const op = machine()->Word32Equal();
+
+ node->ReplaceInput(0, graph()->NewNode(op, input, zero));
+ node->AppendInput(graph()->zone(), zero);
+ NodeProperties::ChangeOp(node, op);
+}
+
+void SimplifiedLowering::DoOrderedNumberToBit(Node* node) {
+ Node* const input = node->InputAt(0);
+
+ node->ReplaceInput(0, graph()->NewNode(machine()->Float64Equal(), input,
+ jsgraph()->Float64Constant(0.0)));
+ node->AppendInput(graph()->zone(), jsgraph()->Int32Constant(0));
+ NodeProperties::ChangeOp(node, machine()->Word32Equal());
+}
+
+void SimplifiedLowering::DoNumberToBit(Node* node) {
+ Node* const input = node->InputAt(0);
+
+ node->ReplaceInput(0, jsgraph()->Float64Constant(0.0));
+ node->AppendInput(graph()->zone(),
+ graph()->NewNode(machine()->Float64Abs(), input));
+ NodeProperties::ChangeOp(node, machine()->Float64LessThan());
+}
+
Node* SimplifiedLowering::ToNumberCode() {
if (!to_number_code_.is_set()) {
Callable callable = CodeFactory::ToNumber(isolate());
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698