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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 262823009: Convert BinadryDoubleOp to MathUnaryInstr double-square if both inputs are the same. Uses less regi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 35712)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -1362,22 +1362,32 @@
Definition* BinaryDoubleOpInstr::Canonicalize(FlowGraph* flow_graph) {
+ if (!HasUses()) return NULL;
+
Definition* result = NULL;
result = CanonicalizeCommutativeArithmetic(op_kind(),
kDoubleCid,
left(),
right());
+ if (result == NULL) {
+ result = CanonicalizeCommutativeArithmetic(op_kind(),
+ kDoubleCid,
+ right(),
+ left());
+ }
if (result != NULL) {
return result;
}
- result = CanonicalizeCommutativeArithmetic(op_kind(),
- kDoubleCid,
- right(),
- left());
- if (result != NULL) {
- return result;
+ if ((op_kind() == Token::kMUL) &&
+ (left()->definition() == right()->definition())) {
+ MathUnaryInstr* math_unary =
+ new MathUnaryInstr(MathUnaryInstr::kDoubleSquare,
+ new Value(left()->definition()),
+ Isolate::kNoDeoptId);
+ flow_graph->InsertBefore(this, math_unary, NULL, Definition::kValue);
+ return math_unary;
}
return this;
@@ -3333,9 +3343,9 @@
const RuntimeEntry& MathUnaryInstr::TargetFunction() const {
switch (kind()) {
- case MethodRecognizer::kMathSin:
+ case MathUnaryInstr::kSin:
return kSinRuntimeEntry;
- case MethodRecognizer::kMathCos:
+ case MathUnaryInstr::kCos:
return kCosRuntimeEntry;
default:
UNREACHABLE();
@@ -3344,6 +3354,19 @@
}
+const char* MathUnaryInstr::KindToCString(MathUnaryKind kind) {
+ switch (kind) {
+ case kIllegal: return "illegal";
+ case kSin: return "sin";
+ case kCos: return "cos";
+ case kSqrt: return "sqrt";
+ case kDoubleSquare: return "double-square";
+ }
+ UNREACHABLE();
+ return "";
+}
+
+
MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs,
intptr_t original_deopt_id,
MergedMathInstr::Kind kind)
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698