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

Unified Diff: src/compiler/operation-typer.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/opcodes.h ('k') | src/compiler/simplified-lowering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/operation-typer.cc
diff --git a/src/compiler/operation-typer.cc b/src/compiler/operation-typer.cc
index 1ac1b8be1dfc669a0d2ed55011d4775dc3c9d6f5..4295a22287f1b24939ecb999358e1032170bc53b 100644
--- a/src/compiler/operation-typer.cc
+++ b/src/compiler/operation-typer.cc
@@ -460,6 +460,16 @@ Type* OperationTyper::NumberTrunc(Type* type) {
return cache_.kIntegerOrMinusZeroOrNaN;
}
+Type* OperationTyper::NumberToBoolean(Type* type) {
+ DCHECK(type->Is(Type::Number()));
+ if (!type->IsInhabited()) return Type::None();
+ if (type->Is(cache_.kZeroish)) return singleton_false_;
+ if (type->Is(Type::PlainNumber()) && (type->Max() < 0 || 0 < type->Min())) {
+ return singleton_true_; // Ruled out nan, -0 and +0.
+ }
+ return Type::Boolean();
+}
+
Type* OperationTyper::NumberToInt32(Type* type) {
DCHECK(type->Is(Type::Number()));
« no previous file with comments | « src/compiler/opcodes.h ('k') | src/compiler/simplified-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698