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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 2145923002: [turbofan] Properly optimize JSToBoolean with Number inputs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // JSToBoolean(x:boolean) => x 823 // JSToBoolean(x:boolean) => x
824 return Replace(input); 824 return Replace(input);
825 } else if (input_type->Is(Type::OrderedNumber())) { 825 } else if (input_type->Is(Type::OrderedNumber())) {
826 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) 826 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0))
827 RelaxEffectsAndControls(node); 827 RelaxEffectsAndControls(node);
828 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, 828 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input,
829 jsgraph()->ZeroConstant())); 829 jsgraph()->ZeroConstant()));
830 node->TrimInputCount(1); 830 node->TrimInputCount(1);
831 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); 831 NodeProperties::ChangeOp(node, simplified()->BooleanNot());
832 return Changed(node); 832 return Changed(node);
833 } else if (input_type->Is(Type::Number())) {
834 // JSToBoolean(x:number) => NumberLessThan(#0,NumberAbs(x))
835 RelaxEffectsAndControls(node);
836 node->ReplaceInput(0, jsgraph()->ZeroConstant());
837 node->ReplaceInput(1, graph()->NewNode(simplified()->NumberAbs(), input));
838 node->TrimInputCount(2);
839 NodeProperties::ChangeOp(node, simplified()->NumberLessThan());
840 return Changed(node);
833 } else if (input_type->Is(Type::String())) { 841 } else if (input_type->Is(Type::String())) {
834 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) 842 // JSToBoolean(x:string) => NumberLessThan(#0,x.length)
835 FieldAccess const access = AccessBuilder::ForStringLength(); 843 FieldAccess const access = AccessBuilder::ForStringLength();
836 Node* length = graph()->NewNode(simplified()->LoadField(access), input, 844 Node* length = graph()->NewNode(simplified()->LoadField(access), input,
837 graph()->start(), graph()->start()); 845 graph()->start(), graph()->start());
838 ReplaceWithValue(node, node, length); 846 ReplaceWithValue(node, node, length);
839 node->ReplaceInput(0, jsgraph()->ZeroConstant()); 847 node->ReplaceInput(0, jsgraph()->ZeroConstant());
840 node->ReplaceInput(1, length); 848 node->ReplaceInput(1, length);
841 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); 849 NodeProperties::ChangeOp(node, simplified()->NumberLessThan());
842 return Changed(node); 850 return Changed(node);
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 } 2059 }
2052 2060
2053 2061
2054 CompilationDependencies* JSTypedLowering::dependencies() const { 2062 CompilationDependencies* JSTypedLowering::dependencies() const {
2055 return dependencies_; 2063 return dependencies_;
2056 } 2064 }
2057 2065
2058 } // namespace compiler 2066 } // namespace compiler
2059 } // namespace internal 2067 } // namespace internal
2060 } // namespace v8 2068 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698