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

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

Issue 10356053: Prettify !(x rel-op y) into (x "!rel-op" y) when possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 8 years, 7 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 | « lib/compiler/implementation/operations.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index 94c13c606302476eb09f8abc939e83d83bd85821..59bee92119f6ab817aa728209247a639ee661146 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -1397,10 +1397,34 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
visitNot(HNot node) {
assert(node.inputs.length == 1);
- beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
- buffer.add('!');
- use(node.inputs[0], JSPrecedence.PREFIX_PRECEDENCE);
- endExpression(JSPrecedence.PREFIX_PRECEDENCE);
+ HInstruction input = node.inputs[0];
+ if (input is HBoolify && isGenerateAtUseSite(input)) {
+ beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
+ assert(node.inputs.length == 1);
+ use(node.inputs[0], JSPrecedence.EQUALITY_PRECEDENCE);
+ buffer.add(' !== true');
+ endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
+ } else if (input is HRelational &&
+ input.builtin &&
+ isGenerateAtUseSite(input)) {
+ Map<String, String> inverseOperator = const <String>{
+ "==" : "!=",
+ "!=" : "==",
+ "===": "!==",
+ "!==": "===",
+ "<" : ">=",
+ "<=" : ">",
+ ">" : "<=",
+ ">=" : "<"
+ };
+ visitInvokeBinary(input,
sra1 2012/05/08 17:47:52 I can't tell from the code, do the preconditions e
Lasse Reichstein Nielsen 2012/05/09 20:13:25 Well spotted. No, it's not excluded. I'll have to
+ inverseOperator[input.operation.name.stringValue]);
+ } else {
+ beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
+ buffer.add('!');
+ use(input, JSPrecedence.PREFIX_PRECEDENCE);
+ endExpression(JSPrecedence.PREFIX_PRECEDENCE);
+ }
}
visitParameterValue(HParameterValue node) {
« no previous file with comments | « lib/compiler/implementation/operations.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698