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

Side by Side Diff: src/compiler/loop-variable-optimizer.h

Issue 2260153002: [turbofan] Induction variable decrement bound analysis. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@DeleteUnusedVar
Patch Set: Simplify if-else loop Created 4 years, 4 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 | src/compiler/loop-variable-optimizer.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #ifndef V8_COMPILER_LOOP_VARIABLE_OPTIMIZER_H_ 5 #ifndef V8_COMPILER_LOOP_VARIABLE_OPTIMIZER_H_
6 #define V8_COMPILER_LOOP_VARIABLE_OPTIMIZER_H_ 6 #define V8_COMPILER_LOOP_VARIABLE_OPTIMIZER_H_
7 7
8 #include "src/zone-containers.h" 8 #include "src/zone-containers.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace compiler { 12 namespace compiler {
13 13
14 class CommonOperatorBuilder; 14 class CommonOperatorBuilder;
15 class Graph; 15 class Graph;
16 class Node; 16 class Node;
17 17
18 class InductionVariable : public ZoneObject { 18 class InductionVariable : public ZoneObject {
19 public: 19 public:
20 Node* phi() const { return phi_; } 20 Node* phi() const { return phi_; }
21 Node* arith() const { return arith_; } 21 Node* arith() const { return arith_; }
22 Node* increment() const { return increment_; } 22 Node* increment() const { return increment_; }
23 Node* init_value() const { return init_value_; } 23 Node* init_value() const { return init_value_; }
24 24
25 enum ConstraintKind { kStrict, kNonStrict }; 25 enum ConstraintKind { kStrict, kNonStrict };
26 enum ArithmeticType { kAddition, kSubtraction };
26 struct Bound { 27 struct Bound {
27 Bound(Node* bound, ConstraintKind kind) : bound(bound), kind(kind) {} 28 Bound(Node* bound, ConstraintKind kind) : bound(bound), kind(kind) {}
28 29
29 Node* bound; 30 Node* bound;
30 ConstraintKind kind; 31 ConstraintKind kind;
31 }; 32 };
32 33
33 const ZoneVector<Bound>& lower_bounds() { return lower_bounds_; } 34 const ZoneVector<Bound>& lower_bounds() { return lower_bounds_; }
34 const ZoneVector<Bound>& upper_bounds() { return upper_bounds_; } 35 const ZoneVector<Bound>& upper_bounds() { return upper_bounds_; }
35 36
37 ArithmeticType Type() { return arithmeticType_; }
38
36 private: 39 private:
37 friend class LoopVariableOptimizer; 40 friend class LoopVariableOptimizer;
38 41
39 InductionVariable(Node* phi, Node* arith, Node* increment, Node* init_value, 42 InductionVariable(Node* phi, Node* arith, Node* increment, Node* init_value,
40 Zone* zone) 43 Zone* zone, ArithmeticType arithmeticType)
41 : phi_(phi), 44 : phi_(phi),
42 arith_(arith), 45 arith_(arith),
43 increment_(increment), 46 increment_(increment),
44 init_value_(init_value), 47 init_value_(init_value),
45 lower_bounds_(zone), 48 lower_bounds_(zone),
46 upper_bounds_(zone) {} 49 upper_bounds_(zone),
50 arithmeticType_(arithmeticType) {}
47 51
48 void AddUpperBound(Node* bound, ConstraintKind kind); 52 void AddUpperBound(Node* bound, ConstraintKind kind);
49 void AddLowerBound(Node* bound, ConstraintKind kind); 53 void AddLowerBound(Node* bound, ConstraintKind kind);
50 54
51 Node* phi_; 55 Node* phi_;
52 Node* arith_; 56 Node* arith_;
53 Node* increment_; 57 Node* increment_;
54 Node* init_value_; 58 Node* init_value_;
55 ZoneVector<Bound> lower_bounds_; 59 ZoneVector<Bound> lower_bounds_;
56 ZoneVector<Bound> upper_bounds_; 60 ZoneVector<Bound> upper_bounds_;
61 ArithmeticType arithmeticType_;
57 }; 62 };
58 63
59 class LoopVariableOptimizer { 64 class LoopVariableOptimizer {
60 public: 65 public:
61 void Run(); 66 void Run();
62 67
63 LoopVariableOptimizer(Graph* graph, CommonOperatorBuilder* common, 68 LoopVariableOptimizer(Graph* graph, CommonOperatorBuilder* common,
64 Zone* zone); 69 Zone* zone);
65 70
66 const ZoneMap<int, InductionVariable*>& induction_variables() { 71 const ZoneMap<int, InductionVariable*>& induction_variables() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 Zone* zone_; 108 Zone* zone_;
104 ZoneMap<int, const VariableLimits*> limits_; 109 ZoneMap<int, const VariableLimits*> limits_;
105 ZoneMap<int, InductionVariable*> induction_vars_; 110 ZoneMap<int, InductionVariable*> induction_vars_;
106 }; 111 };
107 112
108 } // namespace compiler 113 } // namespace compiler
109 } // namespace internal 114 } // namespace internal
110 } // namespace v8 115 } // namespace v8
111 116
112 #endif // V8_COMPILER_LOOP_VARIABLE_OPTIMIZER_H_ 117 #endif // V8_COMPILER_LOOP_VARIABLE_OPTIMIZER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/loop-variable-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698