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

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: 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..a6ec43c938d1f5312d50ff27d16ba4895b76db2a 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -1397,9 +1397,35 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
visitNot(HNot node) {
assert(node.inputs.length == 1);
+ 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);
+ return;
ngeoffray 2012/05/08 09:27:24 I prefer else if than return.
Lasse Reichstein Nielsen 2012/05/08 10:03:33 Done.
+ }
+ if (input is HRelational &&
+ input.builtin &&
+ isGenerateAtUseSite(input)) {
+ Map<String, String> inverseOperator = const <String>{
+ "==" : "!=",
+ "!=" : "==",
+ "===": "!==",
+ "!==": "===",
+ "<" : ">=",
+ "<=" : ">",
+ ">" : "<=",
+ ">=" : "<"
+ };
+ visitInvokeBinary(input,
+ inverseOperator[input.operation.name.stringValue]);
+ return;
ngeoffray 2012/05/08 09:27:24 ditto.
Lasse Reichstein Nielsen 2012/05/08 10:03:33 Done.
+ }
beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
buffer.add('!');
- use(node.inputs[0], JSPrecedence.PREFIX_PRECEDENCE);
+ use(input, JSPrecedence.PREFIX_PRECEDENCE);
endExpression(JSPrecedence.PREFIX_PRECEDENCE);
}
« 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