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

Unified Diff: dart/lib/compiler/implementation/ssa/codegen.dart

Issue 9950014: Eliminate branches on constant conditions during codegen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/ssa/codegen.dart
diff --git a/dart/lib/compiler/implementation/ssa/codegen.dart b/dart/lib/compiler/implementation/ssa/codegen.dart
index 91f179dc4a9da9b9577922cbbe83d70de4e0b08f..aac27f7721d1aee0eb3062055c2afbf6b65a34cc 100644
--- a/dart/lib/compiler/implementation/ssa/codegen.dart
+++ b/dart/lib/compiler/implementation/ssa/codegen.dart
@@ -902,23 +902,37 @@ class SsaCodeGenerator implements HVisitor {
}
visitIf(HIf node) {
+ HInstruction condition = node.inputs[0];
+ int preVisitedBlocks = 1;
Lasse Reichstein Nielsen 2012/03/30 12:56:02 I'd actually prefer to initialize it to zero, and
ahe 2012/03/30 13:15:52 Done.
List<HBasicBlock> dominated = node.block.dominatedBlocks;
HIfBlockInformation info = node.blockInformation;
- startIf(node);
- assert(!isGenerateAtUseSite(node));
- startThen(node);
- assert(node.thenBlock === dominated[0]);
- visitSubGraph(info.thenGraph);
- int preVisitedBlocks = 1;
- endThen(node);
- if (node.hasElse) {
- startElse(node);
- assert(node.elseBlock === dominated[1]);
- visitSubGraph(info.elseGraph);
- preVisitedBlocks = 2;
- endElse(node);
- }
- endIf(node);
+ if (false && condition.isConstant()) {
Lasse Reichstein Nielsen 2012/03/30 12:56:02 "false &&"?
ahe 2012/03/30 13:15:52 Done.
+ HConstant constant = condition;
+ if (constant.constant.isTrue()) {
+ visitSubGraph(info.thenGraph);
Lasse Reichstein Nielsen 2012/03/30 12:56:02 Increment preVisitedBlocks here, or set it to 1, o
+ if (node.hasElse) {
+ preVisitedBlocks = 2;
+ }
+ } else if (node.hasElse) {
+ preVisitedBlocks = 2;
Lasse Reichstein Nielsen 2012/03/30 12:56:02 Here you set it to 1 (possibly with comment about
+ visitSubGraph(info.elseGraph);
Lasse Reichstein Nielsen 2012/03/30 12:56:02 And to 2 after visiting the else-part.
+ }
+ } else {
+ startIf(node);
+ assert(!isGenerateAtUseSite(node));
+ startThen(node);
+ assert(node.thenBlock === dominated[0]);
+ visitSubGraph(info.thenGraph);
+ endThen(node);
+ if (node.hasElse) {
+ startElse(node);
+ assert(node.elseBlock === dominated[1]);
+ visitSubGraph(info.elseGraph);
+ preVisitedBlocks = 2;
+ endElse(node);
+ }
+ endIf(node);
+ }
if (info.joinBlock !== null && info.joinBlock.dominator !== node.block) {
// The join block is dominated by a block in one of the branches.
// The subgraph traversal never reached it, so we visit it here
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698