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

Side by Side Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 11361035: Fix a LICM bug where we were loop hoisting an isntruction, even though that isntruction's inputs we… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('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 (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 part of ssa; 5 part of ssa;
6 6
7 abstract class OptimizationPhase { 7 abstract class OptimizationPhase {
8 String get name; 8 String get name;
9 void visitGraph(HGraph graph); 9 void visitGraph(HGraph graph);
10 } 10 }
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 moveLoopInvariantCode(graph); 883 moveLoopInvariantCode(graph);
884 visitBasicBlock(graph.entry, new ValueSet()); 884 visitBasicBlock(graph.entry, new ValueSet());
885 } 885 }
886 886
887 void moveLoopInvariantCode(HGraph graph) { 887 void moveLoopInvariantCode(HGraph graph) {
888 for (int i = graph.blocks.length - 1; i >= 0; i--) { 888 for (int i = graph.blocks.length - 1; i >= 0; i--) {
889 HBasicBlock block = graph.blocks[i]; 889 HBasicBlock block = graph.blocks[i];
890 if (block.isLoopHeader()) { 890 if (block.isLoopHeader()) {
891 int changesFlags = loopChangesFlags[block.id]; 891 int changesFlags = loopChangesFlags[block.id];
892 HLoopInformation info = block.loopInformation; 892 HLoopInformation info = block.loopInformation;
893 HBasicBlock last = info.getLastBackEdge(); 893 // Iterate over all blocks of this loop. Note that blocks in
894 for (int j = block.id; j <= last.id; j++) { 894 // inner loops are not visited here, but we know they
895 moveLoopInvariantCodeFromBlock(graph.blocks[j], block, changesFlags); 895 // were visited before because we are iterating in post-order.
896 // So instructions that are GVN'ed in an inner loop are in their
897 // loop header, and [info.blocks] contains this loop header.
898 for (HBasicBlock other in info.blocks) {
899 moveLoopInvariantCodeFromBlock(other, block, changesFlags);
896 } 900 }
897 } 901 }
898 } 902 }
899 } 903 }
900 904
901 void moveLoopInvariantCodeFromBlock(HBasicBlock block, 905 void moveLoopInvariantCodeFromBlock(HBasicBlock block,
902 HBasicBlock loopHeader, 906 HBasicBlock loopHeader,
903 int changesFlags) { 907 int changesFlags) {
904 HBasicBlock preheader = loopHeader.predecessors[0]; 908 HBasicBlock preheader = loopHeader.predecessors[0];
kasperl 2012/11/01 14:00:17 Maybe assert that block is part of the loop define
ngeoffray 2012/11/01 16:15:19 Done.
905 int dependsFlags = HInstruction.computeDependsOnFlags(changesFlags); 909 int dependsFlags = HInstruction.computeDependsOnFlags(changesFlags);
906 HInstruction instruction = block.first; 910 HInstruction instruction = block.first;
907 while (instruction != null) { 911 while (instruction != null) {
908 HInstruction next = instruction.next; 912 HInstruction next = instruction.next;
909 if (instruction.useGvn() 913 if (instruction.useGvn()
910 && (instruction is !HCheck) 914 && (instruction is !HCheck)
911 && (instruction.flags & dependsFlags) == 0) { 915 && (instruction.flags & dependsFlags) == 0) {
912 bool loopInvariantInputs = true; 916 bool loopInvariantInputs = true;
913 List<HInstruction> inputs = instruction.inputs; 917 List<HInstruction> inputs = instruction.inputs;
914 for (int i = 0, length = inputs.length; i < length; i++) { 918 for (int i = 0, length = inputs.length; i < length; i++) {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 } 1344 }
1341 1345
1342 // For other fields having setters in the generative constructor body, set 1346 // For other fields having setters in the generative constructor body, set
1343 // the type to UNKNOWN to avoid relying on the type set in the initializer 1347 // the type to UNKNOWN to avoid relying on the type set in the initializer
1344 // list. 1348 // list.
1345 allSetters.forEach((Element element) { 1349 allSetters.forEach((Element element) {
1346 backend.registerFieldConstructor(element, HType.UNKNOWN); 1350 backend.registerFieldConstructor(element, HType.UNKNOWN);
1347 }); 1351 });
1348 } 1352 }
1349 } 1353 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698