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

Side by Side Diff: src/mips/lithium-codegen-mips.cc

Issue 10854053: MIPS: Refactor Math.min/max to be a single HInstruction. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 | « no previous file | src/mips/lithium-mips.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 __ AdduAndCheckForOverflow(ToRegister(result), 1353 __ AdduAndCheckForOverflow(ToRegister(result),
1354 ToRegister(left), 1354 ToRegister(left),
1355 ToRegister(right), 1355 ToRegister(right),
1356 overflow); // Reg at also used as scratch. 1356 overflow); // Reg at also used as scratch.
1357 } 1357 }
1358 DeoptimizeIf(lt, instr->environment(), overflow, Operand(zero_reg)); 1358 DeoptimizeIf(lt, instr->environment(), overflow, Operand(zero_reg));
1359 } 1359 }
1360 } 1360 }
1361 1361
1362 1362
1363 void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
1364 LOperand* left = instr->InputAt(0);
1365 LOperand* right = instr->InputAt(1);
1366 HMathMinMax::Operation operation = instr->hydrogen()->operation();
1367 Condition condition = (operation == HMathMinMax::kMathMin) ? le : ge;
1368 if (instr->hydrogen()->representation().IsInteger32()) {
1369 Register left_reg = ToRegister(left);
1370 Operand right_op = (right->IsRegister() || right->IsConstantOperand())
1371 ? ToOperand(right)
1372 : Operand(EmitLoadRegister(right, at));
1373 Register result_reg = ToRegister(instr->result());
1374 Label return_right, done;
1375 if (!result_reg.is(left_reg)) {
1376 __ Branch(&return_right, NegateCondition(condition), left_reg, right_op);
1377 __ mov(result_reg, left_reg);
1378 __ Branch(&done);
1379 }
1380 __ Branch(&done, condition, left_reg, right_op);
1381 __ bind(&return_right);
1382 __ Addu(result_reg, zero_reg, right_op);
1383 __ bind(&done);
1384 } else {
1385 ASSERT(instr->hydrogen()->representation().IsDouble());
1386 FPURegister left_reg = ToDoubleRegister(left);
1387 FPURegister right_reg = ToDoubleRegister(right);
1388 FPURegister result_reg = ToDoubleRegister(instr->result());
1389 Label check_nan_left, check_zero, return_left, return_right, done;
1390 __ BranchF(&check_zero, &check_nan_left, eq, left_reg, right_reg);
1391 __ BranchF(&return_left, NULL, condition, left_reg, right_reg);
1392 __ Branch(&return_right);
1393
1394 __ bind(&check_zero);
1395 // left == right != 0.
1396 __ BranchF(&return_left, NULL, ne, left_reg, kDoubleRegZero);
1397 // At this point, both left and right are either 0 or -0.
1398 if (operation == HMathMinMax::kMathMin) {
1399 // We could use a single 'vorr' instruction here if we had NEON support.
Yang 2012/08/09 08:30:08 Comment only applies to ARM.
1400 __ neg_d(left_reg, left_reg);
1401 __ sub_d(result_reg, left_reg, right_reg);
1402 __ neg_d(result_reg, result_reg);
1403 } else {
1404 // Since we operate on +0 and/or -0, vadd and vand have the same effect;
Yang 2012/08/09 08:30:08 Comment only applies to ARM.
1405 // the decision for vadd is easy because vand is a NEON instruction.
1406 __ add_d(result_reg, left_reg, right_reg);
1407 }
1408 __ Branch(&done);
1409
1410 __ bind(&check_nan_left);
1411 // left == NaN.
1412 __ BranchF(NULL, &return_left, eq, left_reg, left_reg);
1413 __ bind(&return_right);
1414 if (!right_reg.is(result_reg)) {
1415 __ mov_d(result_reg, right_reg);
1416 }
1417 __ Branch(&done);
1418
1419 __ bind(&return_left);
1420 if (!left_reg.is(result_reg)) {
1421 __ mov_d(result_reg, left_reg);
1422 }
1423 __ bind(&done);
1424 }
1425 }
1426
1427
1363 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { 1428 void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
1364 DoubleRegister left = ToDoubleRegister(instr->InputAt(0)); 1429 DoubleRegister left = ToDoubleRegister(instr->InputAt(0));
1365 DoubleRegister right = ToDoubleRegister(instr->InputAt(1)); 1430 DoubleRegister right = ToDoubleRegister(instr->InputAt(1));
1366 DoubleRegister result = ToDoubleRegister(instr->result()); 1431 DoubleRegister result = ToDoubleRegister(instr->result());
1367 switch (instr->op()) { 1432 switch (instr->op()) {
1368 case Token::ADD: 1433 case Token::ADD:
1369 __ add_d(result, left, right); 1434 __ add_d(result, left, right);
1370 break; 1435 break;
1371 case Token::SUB: 1436 case Token::SUB:
1372 __ sub_d(result, left, right); 1437 __ sub_d(result, left, right);
(...skipping 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 __ Subu(scratch, result, scratch); 5304 __ Subu(scratch, result, scratch);
5240 __ lw(result, FieldMemOperand(scratch, 5305 __ lw(result, FieldMemOperand(scratch,
5241 FixedArray::kHeaderSize - kPointerSize)); 5306 FixedArray::kHeaderSize - kPointerSize));
5242 __ bind(&done); 5307 __ bind(&done);
5243 } 5308 }
5244 5309
5245 5310
5246 #undef __ 5311 #undef __
5247 5312
5248 } } // namespace v8::internal 5313 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698