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

Unified Diff: runtime/vm/intermediate_language_arm.cc

Issue 19695007: Optimize double min/max by reducing the code size (reusing left register as result removes the need… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_arm.cc
===================================================================
--- runtime/vm/intermediate_language_arm.cc (revision 25350)
+++ runtime/vm/intermediate_language_arm.cc (working copy)
@@ -3355,19 +3355,28 @@
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
summary->set_in(0, Location::RequiresFpuRegister());
summary->set_in(1, Location::RequiresFpuRegister());
+ // Reuse the left register so that code can be made shorter.
+ summary->set_out(Location::SameAsFirstInput());
summary->set_temp(0, Location::RequiresRegister());
- summary->set_out(Location::RequiresFpuRegister());
return summary;
}
ASSERT(result_cid() == kSmiCid);
- UNIMPLEMENTED();
- return NULL;
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ summary->set_in(1, Location::RequiresRegister());
+ // Reuse the left register so that code can be made shorter.
+ summary->set_out(Location::SameAsFirstInput());
+ return summary;
}
void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
ASSERT((op_kind() == MethodRecognizer::kMathMin) ||
(op_kind() == MethodRecognizer::kMathMax));
+ const intptr_t is_min = (op_kind() == MethodRecognizer::kMathMin);
if (result_cid() == kDoubleCid) {
Label done, returns_nan, are_equal;
DRegister left = EvenDRegisterOf(locs()->in(0).fpu_reg());
@@ -3378,14 +3387,10 @@
__ vmstat();
__ b(&returns_nan, VS);
__ b(&are_equal, EQ);
- const intptr_t is_min = (op_kind() == MethodRecognizer::kMathMin);
- const Condition double_condition =
- is_min ? TokenKindToDoubleCondition(Token::kLT)
- : TokenKindToDoubleCondition(Token::kGT);
const Condition neg_double_condition =
is_min ? TokenKindToDoubleCondition(Token::kGTE)
: TokenKindToDoubleCondition(Token::kLTE);
- __ vmovd(result, left, double_condition);
+ ASSERT(left == result);
__ vmovd(result, right, neg_double_condition);
__ b(&done);
@@ -3403,17 +3408,27 @@
__ vmovrrd(IP, temp, left); // Sign bit is in bit 31 of temp.
__ cmp(temp, ShifterOperand(0));
if (is_min) {
- __ vmovd(result, left, LT);
+ ASSERT(left == result);
__ vmovd(result, right, GE);
} else {
__ vmovd(result, right, LT);
- __ vmovd(result, left, GE);
+ ASSERT(left == result);
}
__ Bind(&done);
return;
}
+
ASSERT(result_cid() == kSmiCid);
- UNIMPLEMENTED();
+ Register left = locs()->in(0).reg();
+ Register right = locs()->in(1).reg();
+ Register result = locs()->out().reg();
+ __ cmp(left, ShifterOperand(right));
+ ASSERT(result == left);
+ if (is_min) {
+ __ mov(result, ShifterOperand(right), GE);
regis 2013/07/23 19:45:47 GT would be more intuitive than GE, but it does no
srdjan 2013/07/23 20:34:01 Done.
+ } else {
+ __ mov(result, ShifterOperand(right), LT);
+ }
}
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698