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

Unified Diff: runtime/vm/intermediate_language_mips.cc

Issue 19792007: Recognize Math's min and max function for doubles and inline the operation. (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
Index: runtime/vm/intermediate_language_mips.cc
===================================================================
--- runtime/vm/intermediate_language_mips.cc (revision 25251)
+++ runtime/vm/intermediate_language_mips.cc (working copy)
@@ -3085,6 +3085,57 @@
}
+LocationSummary* MathMinMaxInstr::MakeLocationSummary() const {
+ if (result_cid() == kDoubleCid) {
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 1;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresFpuRegister());
+ summary->set_in(1, Location::RequiresFpuRegister());
+ summary->set_temp(0, Location::RequiresRegister());
+ summary->set_out(Location::RequiresFpuRegister());
+ return summary;
+ }
+ ASSERT(result_cid() == kSmiCid);
+ UNIMPLEMENTED();
+ return NULL;
+}
+
+
+void MathMinMaxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ if (result_cid() == kDoubleCid) {
+ Label done, is_nan, is_left;
+ DRegister left = locs()->in(0).fpu_reg();
+ DRegister right = locs()->in(1).fpu_reg();
+ DRegister result = locs()->out().fpu_reg();
+ Register temp = locs()->temp(0).reg();
+ __ cund(left, right);
+ __ bc1t(&is_nan);
+ if (op_kind() == MethodRecognizer::kMathMin) {
+ __ coltd(left, right);
+ } else {
+ ASSERT(op_kind() == MethodRecognizer::kMathMax);
+ __ coltd(right, left);
+ }
+ __ bc1t(&is_left);
+ __ movd(result, right);
zra 2013/07/22 16:21:02 It would be okay to add a TODO here for me to add
srdjan 2013/07/22 16:42:48 Done.
+ __ b(&done);
+ __ Bind(&is_left);
+ __ movd(result, right);
+ __ b(&done);
+ __ Bind(&is_nan);
+ static double kNaN = NAN;
+ __ LoadImmediate(temp, reinterpret_cast<int32_t>(&kNaN));
+ __ ldc1(result, Address(temp, 0));
zra 2013/07/22 16:21:02 __ LoadDImmediate(result, NAN);
srdjan 2013/07/22 16:42:48 Done.
srdjan 2013/07/22 17:07:57 Actually, there is no LoadDImmedaite on MIPS yet.
+ __ Bind(&done);
+ return;
+ }
+ ASSERT(result_cid() == kSmiCid);
+ UNIMPLEMENTED();
+}
+
+
LocationSummary* UnarySmiOpInstr::MakeLocationSummary() const {
const intptr_t kNumInputs = 1;
const intptr_t kNumTemps = 0;
@@ -3237,7 +3288,7 @@
void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- // For pow-function return NAN if exponent is NAN.
+ // For pow-function return NaN if exponent is NaN.
Label do_call, skip_call;
if (recognized_kind() == MethodRecognizer::kDoublePow) {
DRegister exp = locs()->in(1).fpu_reg();

Powered by Google App Engine
This is Rietveld 408576698