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

Side by Side Diff: pkg/compiler/lib/src/ssa/codegen_helpers.dart

Issue 2339853004: Avoid merging conditions across loop boundary (Closed)
Patch Set: Add test Created 4 years, 3 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
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 import '../compiler.dart' show Compiler; 5 import '../compiler.dart' show Compiler;
6 import '../constants/values.dart'; 6 import '../constants/values.dart';
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../js_backend/js_backend.dart'; 8 import '../js_backend/js_backend.dart';
9 import '../types/types.dart'; 9 import '../types/types.dart';
10 import '../universe/selector.dart' show Selector; 10 import '../universe/selector.dart' show Selector;
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (user is HCreate) return true; 674 if (user is HCreate) return true;
675 // A [HForeign] instruction uses operators and if we generate [input] at use 675 // A [HForeign] instruction uses operators and if we generate [input] at use
676 // site, the precedence or evaluation order might be wrong. 676 // site, the precedence or evaluation order might be wrong.
677 if (user is HForeign) return false; 677 if (user is HForeign) return false;
678 // A [HCheck] instruction with control flow uses its input 678 // A [HCheck] instruction with control flow uses its input
679 // multiple times, so we avoid generating it at use site. 679 // multiple times, so we avoid generating it at use site.
680 if (user is HCheck && user.isControlFlow()) return false; 680 if (user is HCheck && user.isControlFlow()) return false;
681 // A [HIs] instruction uses its input multiple times, so we 681 // A [HIs] instruction uses its input multiple times, so we
682 // avoid generating it at use site. 682 // avoid generating it at use site.
683 if (user is HIs) return false; 683 if (user is HIs) return false;
684 return true; 684 // Avoid code motion into a loop.
685 return user.hasSameLoopHeaderAs(input);
685 } 686 }
686 687
687 void visitBasicBlock(HBasicBlock block) { 688 void visitBasicBlock(HBasicBlock block) {
688 if (block.last is! HIf) return; 689 if (block.last is! HIf) return;
689 HIf startIf = block.last; 690 HIf startIf = block.last;
690 HBasicBlock end = startIf.joinBlock; 691 HBasicBlock end = startIf.joinBlock;
691 692
692 // We check that the structure is the following: 693 // We check that the structure is the following:
693 // If 694 // If
694 // / \ 695 // / \
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 788 }
788 789
789 // If [thenInput] is defined in the first predecessor, then it is only used 790 // If [thenInput] is defined in the first predecessor, then it is only used
790 // by [phi] and can be generated at use site. 791 // by [phi] and can be generated at use site.
791 if (identical(thenInput.block, end.predecessors[0])) { 792 if (identical(thenInput.block, end.predecessors[0])) {
792 assert(thenInput.usedBy.length == 1); 793 assert(thenInput.usedBy.length == 1);
793 markAsGenerateAtUseSite(thenInput); 794 markAsGenerateAtUseSite(thenInput);
794 } 795 }
795 } 796 }
796 } 797 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/27354_test.dart » ('j') | tests/compiler/dart2js_extra/27354_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698