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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 return this; 1355 return this;
1356 } 1356 }
1357 1357
1358 1358
1359 Definition* FloatToDoubleInstr::Canonicalize(FlowGraph* flow_graph) { 1359 Definition* FloatToDoubleInstr::Canonicalize(FlowGraph* flow_graph) {
1360 return HasUses() ? this : NULL; 1360 return HasUses() ? this : NULL;
1361 } 1361 }
1362 1362
1363 1363
1364 Definition* BinaryDoubleOpInstr::Canonicalize(FlowGraph* flow_graph) { 1364 Definition* BinaryDoubleOpInstr::Canonicalize(FlowGraph* flow_graph) {
1365 if (!HasUses()) return NULL;
1366
1365 Definition* result = NULL; 1367 Definition* result = NULL;
1366 1368
1367 result = CanonicalizeCommutativeArithmetic(op_kind(), 1369 result = CanonicalizeCommutativeArithmetic(op_kind(),
1368 kDoubleCid, 1370 kDoubleCid,
1369 left(), 1371 left(),
1370 right()); 1372 right());
1373 if (result == NULL) {
1374 result = CanonicalizeCommutativeArithmetic(op_kind(),
1375 kDoubleCid,
1376 right(),
1377 left());
1378 }
1371 if (result != NULL) { 1379 if (result != NULL) {
1372 return result; 1380 return result;
1373 } 1381 }
1374 1382
1375 result = CanonicalizeCommutativeArithmetic(op_kind(), 1383 if ((op_kind() == Token::kMUL) &&
1376 kDoubleCid, 1384 (left()->definition() == right()->definition())) {
1377 right(), 1385 MathUnaryInstr* math_unary =
1378 left()); 1386 new MathUnaryInstr(MathUnaryInstr::kDoubleSquare,
1379 if (result != NULL) { 1387 new Value(left()->definition()),
1380 return result; 1388 Isolate::kNoDeoptId);
1389 flow_graph->InsertBefore(this, math_unary, NULL, Definition::kValue);
1390 return math_unary;
1381 } 1391 }
1382 1392
1383 return this; 1393 return this;
1384 } 1394 }
1385 1395
1386 1396
1387 Definition* BinarySmiOpInstr::Canonicalize(FlowGraph* flow_graph) { 1397 Definition* BinarySmiOpInstr::Canonicalize(FlowGraph* flow_graph) {
1388 Definition* result = NULL; 1398 Definition* result = NULL;
1389 1399
1390 result = CanonicalizeCommutativeArithmetic(op_kind(), 1400 result = CanonicalizeCommutativeArithmetic(op_kind(),
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 "libc_cos", reinterpret_cast<RuntimeFunction>( 3336 "libc_cos", reinterpret_cast<RuntimeFunction>(
3327 static_cast<UnaryMathCFunction>(&cos)), 1, true, true); 3337 static_cast<UnaryMathCFunction>(&cos)), 1, true, true);
3328 3338
3329 extern const RuntimeEntry kSinRuntimeEntry( 3339 extern const RuntimeEntry kSinRuntimeEntry(
3330 "libc_sin", reinterpret_cast<RuntimeFunction>( 3340 "libc_sin", reinterpret_cast<RuntimeFunction>(
3331 static_cast<UnaryMathCFunction>(&sin)), 1, true, true); 3341 static_cast<UnaryMathCFunction>(&sin)), 1, true, true);
3332 3342
3333 3343
3334 const RuntimeEntry& MathUnaryInstr::TargetFunction() const { 3344 const RuntimeEntry& MathUnaryInstr::TargetFunction() const {
3335 switch (kind()) { 3345 switch (kind()) {
3336 case MethodRecognizer::kMathSin: 3346 case MathUnaryInstr::kSin:
3337 return kSinRuntimeEntry; 3347 return kSinRuntimeEntry;
3338 case MethodRecognizer::kMathCos: 3348 case MathUnaryInstr::kCos:
3339 return kCosRuntimeEntry; 3349 return kCosRuntimeEntry;
3340 default: 3350 default:
3341 UNREACHABLE(); 3351 UNREACHABLE();
3342 } 3352 }
3343 return kSinRuntimeEntry; 3353 return kSinRuntimeEntry;
3344 } 3354 }
3345 3355
3346 3356
3357 const char* MathUnaryInstr::KindToCString(MathUnaryKind kind) {
3358 switch (kind) {
3359 case kIllegal: return "illegal";
3360 case kSin: return "sin";
3361 case kCos: return "cos";
3362 case kSqrt: return "sqrt";
3363 case kDoubleSquare: return "double-square";
3364 }
3365 UNREACHABLE();
3366 return "";
3367 }
3368
3369
3347 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, 3370 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs,
3348 intptr_t original_deopt_id, 3371 intptr_t original_deopt_id,
3349 MergedMathInstr::Kind kind) 3372 MergedMathInstr::Kind kind)
3350 : inputs_(inputs), 3373 : inputs_(inputs),
3351 kind_(kind) { 3374 kind_(kind) {
3352 ASSERT(inputs_->length() == InputCountFor(kind_)); 3375 ASSERT(inputs_->length() == InputCountFor(kind_));
3353 for (intptr_t i = 0; i < inputs_->length(); ++i) { 3376 for (intptr_t i = 0; i < inputs_->length(); ++i) {
3354 ASSERT((*inputs)[i] != NULL); 3377 ASSERT((*inputs)[i] != NULL);
3355 (*inputs)[i]->set_instruction(this); 3378 (*inputs)[i]->set_instruction(this);
3356 (*inputs)[i]->set_use_index(i); 3379 (*inputs)[i]->set_use_index(i);
(...skipping 16 matching lines...) Expand all
3373 case Token::kTRUNCDIV: return 0; 3396 case Token::kTRUNCDIV: return 0;
3374 case Token::kMOD: return 1; 3397 case Token::kMOD: return 1;
3375 default: UNIMPLEMENTED(); return -1; 3398 default: UNIMPLEMENTED(); return -1;
3376 } 3399 }
3377 } 3400 }
3378 3401
3379 3402
3380 #undef __ 3403 #undef __
3381 3404
3382 } // namespace dart 3405 } // namespace dart
OLDNEW
« 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