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

Side by Side Diff: runtime/vm/flow_graph_optimizer.h

Issue 12218181: Recognize pattern (a << b) & c with c being a positive Smi and allow left shift to truncate the res… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_ 5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_
6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/flow_graph.h" 9 #include "vm/flow_graph.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 template <typename T> class GrowableArray; 13 template <typename T> class GrowableArray;
14 template <typename T> class DirectChainedHashMap; 14 template <typename T> class DirectChainedHashMap;
15 template <typename T> class PointerKeyValueTrait; 15 template <typename T> class PointerKeyValueTrait;
16 16
17 class FlowGraphOptimizer : public FlowGraphVisitor { 17 class FlowGraphOptimizer : public FlowGraphVisitor {
18 public: 18 public:
19 explicit FlowGraphOptimizer(FlowGraph* flow_graph) 19 explicit FlowGraphOptimizer(FlowGraph* flow_graph)
20 : FlowGraphVisitor(flow_graph->reverse_postorder()), 20 : FlowGraphVisitor(flow_graph->reverse_postorder()),
21 flow_graph_(flow_graph) { } 21 flow_graph_(flow_graph) { }
22 virtual ~FlowGraphOptimizer() {} 22 virtual ~FlowGraphOptimizer() {}
23 23
24 // Use ICData to optimize, replace or eliminate instructions. 24 // Use ICData to optimize, replace or eliminate instructions.
25 void ApplyICData(); 25 void ApplyICData();
26 26
27 // Use propagated class ids to optimize, replace or eliminate instructions. 27 // Use propagated class ids to optimize, replace or eliminate instructions.
28 void ApplyClassIds(); 28 void ApplyClassIds();
29 29
30 // Optimize (a << b) & c pattern: if c is a positive smi, then the
31 // shift can be a truncating Smi shift and result is always Smi.
32 void TryOptimizeLeftShiftWithBitAndPattern();
33
30 void Canonicalize(); 34 void Canonicalize();
31 35
32 void EliminateDeadPhis(); 36 void EliminateDeadPhis();
33 37
34 void SelectRepresentations(); 38 void SelectRepresentations();
35 39
36 void PropagateSminess(); 40 void PropagateSminess();
37 41
38 void InferSmiRanges(); 42 void InferSmiRanges();
39 43
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 MethodRecognizer::Kind recognized_kind); 129 MethodRecognizer::Kind recognized_kind);
126 130
127 void HandleRelationalOp(RelationalOpInstr* comp); 131 void HandleRelationalOp(RelationalOpInstr* comp);
128 132
129 // Visit an equality compare. The current instruction can be the 133 // Visit an equality compare. The current instruction can be the
130 // comparison itself or a branch on the comparison. 134 // comparison itself or a branch on the comparison.
131 template <typename T> 135 template <typename T>
132 void HandleEqualityCompare(EqualityCompareInstr* comp, 136 void HandleEqualityCompare(EqualityCompareInstr* comp,
133 T current_instruction); 137 T current_instruction);
134 138
139 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr,
140 Value* left,
141 Value* right);
142
135 FlowGraph* flow_graph_; 143 FlowGraph* flow_graph_;
136 144
137 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); 145 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer);
138 }; 146 };
139 147
140 148
141 class ParsedFunction; 149 class ParsedFunction;
142 150
143 151
144 // Loop invariant code motion. 152 // Loop invariant code motion.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 238
231 // Worklists of blocks and definitions. 239 // Worklists of blocks and definitions.
232 GrowableArray<BlockEntryInstr*> block_worklist_; 240 GrowableArray<BlockEntryInstr*> block_worklist_;
233 GrowableArray<Definition*> definition_worklist_; 241 GrowableArray<Definition*> definition_worklist_;
234 }; 242 };
235 243
236 244
237 } // namespace dart 245 } // namespace dart
238 246
239 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 247 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698