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

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

Issue 10565025: Fix GVN for loops. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | tests/language/gvn_test.dart » ('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 interface OptimizationPhase { 5 interface OptimizationPhase {
6 String get name(); 6 String get name();
7 void visitGraph(HGraph graph); 7 void visitGraph(HGraph graph);
8 } 8 }
9 9
10 class SsaOptimizerTask extends CompilerTask { 10 class SsaOptimizerTask extends CompilerTask {
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 896 }
897 } 897 }
898 898
899 bool isInputDefinedAfterDominator(HInstruction input, 899 bool isInputDefinedAfterDominator(HInstruction input,
900 HBasicBlock dominator) { 900 HBasicBlock dominator) {
901 return input.block.id > dominator.id; 901 return input.block.id > dominator.id;
902 } 902 }
903 903
904 void visitBasicBlock(HBasicBlock block, ValueSet values) { 904 void visitBasicBlock(HBasicBlock block, ValueSet values) {
905 HInstruction instruction = block.first; 905 HInstruction instruction = block.first;
906 if (block.isLoopHeader()) {
907 int flags = loopChangesFlags[block.id];
908 if (flags != 0) {
909 values.kill(flags);
910 }
911 }
906 while (instruction !== null) { 912 while (instruction !== null) {
907 HInstruction next = instruction.next; 913 HInstruction next = instruction.next;
908 int flags = instruction.getChangesFlags(); 914 int flags = instruction.getChangesFlags();
909 if (flags != 0) { 915 if (flags != 0) {
910 assert(!instruction.useGvn()); 916 assert(!instruction.useGvn());
911 values.kill(flags); 917 values.kill(flags);
912 } else if (instruction.useGvn()) { 918 } else if (instruction.useGvn()) {
913 HInstruction other = values.lookup(instruction); 919 HInstruction other = values.lookup(instruction);
914 if (other !== null) { 920 if (other !== null) {
915 assert(other.gvnEquals(instruction) && instruction.gvnEquals(other)); 921 assert(other.gvnEquals(instruction) && instruction.gvnEquals(other));
(...skipping 13 matching lines...) Expand all
929 ValueSet successorValues = (i == length - 1) ? values : values.copy(); 935 ValueSet successorValues = (i == length - 1) ? values : values.copy();
930 // If we have no values in our set, we do not have to kill 936 // If we have no values in our set, we do not have to kill
931 // anything. Also, if the range of block ids from the current 937 // anything. Also, if the range of block ids from the current
932 // block to the dominated block is empty, there is no blocks on 938 // block to the dominated block is empty, there is no blocks on
933 // any path from the current block to the dominated block so we 939 // any path from the current block to the dominated block so we
934 // don't have to do anything either. 940 // don't have to do anything either.
935 assert(block.id < dominated.id); 941 assert(block.id < dominated.id);
936 if (!successorValues.isEmpty() && block.id + 1 < dominated.id) { 942 if (!successorValues.isEmpty() && block.id + 1 < dominated.id) {
937 visited.clear(); 943 visited.clear();
938 int changesFlags = getChangesFlagsForDominatedBlock(block, dominated); 944 int changesFlags = getChangesFlagsForDominatedBlock(block, dominated);
939 successorValues.kill(changesFlags); 945 successorValues.kill(changesFlags);
kasperl 2012/06/18 05:51:33 Would it make sense to do a fast check (changesFla
Mads Ager (google) 2012/06/18 08:01:13 Added early bailout to ValueSet.kill and called it
940 } 946 }
941 visitBasicBlock(dominated, successorValues); 947 visitBasicBlock(dominated, successorValues);
942 } 948 }
943 } 949 }
944 950
945 void computeChangesFlags(HGraph graph) { 951 void computeChangesFlags(HGraph graph) {
946 // Create the changes flags lists. Make sure to initialize the 952 // Create the changes flags lists. Make sure to initialize the
947 // loop changes flags list to zero so we can use bitwise or when 953 // loop changes flags list to zero so we can use bitwise or when
948 // propagating loop changes upwards. 954 // propagating loop changes upwards.
949 final int length = graph.blocks.length; 955 final int length = graph.blocks.length;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 // the if block terminates. So any use of the instruction 1167 // the if block terminates. So any use of the instruction
1162 // after the join block should be changed to the new 1168 // after the join block should be changed to the new
1163 // instruction. 1169 // instruction.
1164 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); 1170 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType);
1165 } 1171 }
1166 // TODO(ngeoffray): Also change uses for the then block on a HType 1172 // TODO(ngeoffray): Also change uses for the then block on a HType
1167 // that knows it is not of a specific Type. 1173 // that knows it is not of a specific Type.
1168 } 1174 }
1169 } 1175 }
1170 } 1176 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/gvn_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698