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

Side by Side Diff: src/mips64/macro-assembler-mips64.cc

Issue 2556793003: MIPS[64]: Fix `MIPS: Improve Float(32|64)(Max|Min)`. (Closed)
Patch Set: Modified according comments. Created 4 years 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
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | test/cctest/test-macro-assembler-mips.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #if V8_TARGET_ARCH_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 #include "src/base/division-by-constant.h" 9 #include "src/base/division-by-constant.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 6284 matching lines...) Expand 10 before | Expand all | Expand 10 after
6295 // Check that neither is a smi. 6295 // Check that neither is a smi.
6296 STATIC_ASSERT(kSmiTag == 0); 6296 STATIC_ASSERT(kSmiTag == 0);
6297 And(scratch1, first, Operand(second)); 6297 And(scratch1, first, Operand(second));
6298 JumpIfSmi(scratch1, failure); 6298 JumpIfSmi(scratch1, failure);
6299 JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1, 6299 JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1,
6300 scratch2, failure); 6300 scratch2, failure);
6301 } 6301 }
6302 6302
6303 void MacroAssembler::Float32Max(FPURegister dst, FPURegister src1, 6303 void MacroAssembler::Float32Max(FPURegister dst, FPURegister src1,
6304 FPURegister src2, Label* out_of_line) { 6304 FPURegister src2, Label* out_of_line) {
6305 DCHECK(!src1.is(src2)); 6305 if (src1.is(src2)) {
6306 Move_s(dst, src1);
6307 return;
6308 }
6306 6309
6307 // Check if one of operands is NaN. 6310 // Check if one of operands is NaN.
6308 BranchF32(nullptr, out_of_line, eq, src1, src2); 6311 BranchF32(nullptr, out_of_line, eq, src1, src2);
6309 6312
6310 if (kArchVariant >= kMips64r6) { 6313 if (kArchVariant >= kMips64r6) {
6311 max_s(dst, src1, src2); 6314 max_s(dst, src1, src2);
6312 } else { 6315 } else {
6313 Label return_left, return_right, done; 6316 Label return_left, return_right, done;
6314 6317
6315 c(OLT, S, src1, src2); 6318 BranchF32(&return_right, nullptr, lt, src1, src2);
6316 bc1t(&return_right); 6319 BranchF32(&return_left, nullptr, lt, src2, src1);
6317 nop();
6318
6319 c(OLT, S, src2, src1);
6320 bc1t(&return_left);
6321 nop();
6322 6320
6323 // Operands are equal, but check for +/-0. 6321 // Operands are equal, but check for +/-0.
6324 mfc1(t8, src1); 6322 mfc1(t8, src1);
6325 dsll32(t8, t8, 0); 6323 dsll32(t8, t8, 0);
6326 beq(t8, zero_reg, &return_left); 6324 Branch(&return_left, eq, t8, Operand(zero_reg));
6327 nop(); 6325 Branch(&return_right);
6328 b(&return_right);
6329 nop();
6330 6326
6331 bind(&return_right); 6327 bind(&return_right);
6332 if (!src2.is(dst)) { 6328 if (!src2.is(dst)) {
6333 Move_s(dst, src2); 6329 Move_s(dst, src2);
6334 } 6330 }
6335 b(&done); 6331 Branch(&done);
6336 nop();
6337 6332
6338 bind(&return_left); 6333 bind(&return_left);
6339 if (!src1.is(dst)) { 6334 if (!src1.is(dst)) {
6340 Move_s(dst, src1); 6335 Move_s(dst, src1);
6341 } 6336 }
6342 6337
6343 bind(&done); 6338 bind(&done);
6344 } 6339 }
6345 } 6340 }
6346 6341
6347 void MacroAssembler::Float32MaxOutOfLine(FPURegister dst, FPURegister src1, 6342 void MacroAssembler::Float32MaxOutOfLine(FPURegister dst, FPURegister src1,
6348 FPURegister src2) { 6343 FPURegister src2) {
6349 DCHECK(!src1.is(src2));
6350 add_s(dst, src1, src2); 6344 add_s(dst, src1, src2);
6351 } 6345 }
6352 6346
6353 void MacroAssembler::Float32Min(FPURegister dst, FPURegister src1, 6347 void MacroAssembler::Float32Min(FPURegister dst, FPURegister src1,
6354 FPURegister src2, Label* out_of_line) { 6348 FPURegister src2, Label* out_of_line) {
6355 DCHECK(!src1.is(src2)); 6349 if (src1.is(src2)) {
6350 Move_s(dst, src1);
6351 return;
6352 }
6356 6353
6357 // Check if one of operands is NaN. 6354 // Check if one of operands is NaN.
6358 BranchF32(nullptr, out_of_line, eq, src1, src2); 6355 BranchF32(nullptr, out_of_line, eq, src1, src2);
6359 6356
6360 if (kArchVariant >= kMips64r6) { 6357 if (kArchVariant >= kMips64r6) {
6361 min_s(dst, src1, src2); 6358 min_s(dst, src1, src2);
6362 } else { 6359 } else {
6363 Label return_left, return_right, done; 6360 Label return_left, return_right, done;
6364 6361
6365 c(OLT, S, src1, src2); 6362 BranchF32(&return_left, nullptr, lt, src1, src2);
6366 bc1t(&return_left); 6363 BranchF32(&return_right, nullptr, lt, src2, src1);
6367 nop();
6368
6369 c(OLT, S, src2, src1);
6370 bc1t(&return_right);
6371 nop();
6372 6364
6373 // Left equals right => check for -0. 6365 // Left equals right => check for -0.
6374 mfc1(t8, src1); 6366 mfc1(t8, src1);
6375 dsll32(t8, t8, 0); 6367 dsll32(t8, t8, 0);
6376 beq(t8, zero_reg, &return_right); 6368 Branch(&return_right, eq, t8, Operand(zero_reg));
6377 nop(); 6369 Branch(&return_left);
6378 b(&return_left);
6379 nop();
6380 6370
6381 bind(&return_right); 6371 bind(&return_right);
6382 if (!src2.is(dst)) { 6372 if (!src2.is(dst)) {
6383 Move_s(dst, src2); 6373 Move_s(dst, src2);
6384 } 6374 }
6385 b(&done); 6375 Branch(&done);
6386 nop();
6387 6376
6388 bind(&return_left); 6377 bind(&return_left);
6389 if (!src1.is(dst)) { 6378 if (!src1.is(dst)) {
6390 Move_s(dst, src1); 6379 Move_s(dst, src1);
6391 } 6380 }
6392 6381
6393 bind(&done); 6382 bind(&done);
6394 } 6383 }
6395 } 6384 }
6396 6385
6397 void MacroAssembler::Float32MinOutOfLine(FPURegister dst, FPURegister src1, 6386 void MacroAssembler::Float32MinOutOfLine(FPURegister dst, FPURegister src1,
6398 FPURegister src2) { 6387 FPURegister src2) {
6399 DCHECK(!src1.is(src2));
6400 add_s(dst, src1, src2); 6388 add_s(dst, src1, src2);
6401 } 6389 }
6402 6390
6403 void MacroAssembler::Float64Max(FPURegister dst, FPURegister src1, 6391 void MacroAssembler::Float64Max(FPURegister dst, FPURegister src1,
6404 FPURegister src2, Label* out_of_line) { 6392 FPURegister src2, Label* out_of_line) {
6405 DCHECK(!src1.is(src2)); 6393 if (src1.is(src2)) {
6394 Move_d(dst, src1);
6395 return;
6396 }
6406 6397
6407 // Check if one of operands is NaN. 6398 // Check if one of operands is NaN.
6408 BranchF64(nullptr, out_of_line, eq, src1, src2); 6399 BranchF64(nullptr, out_of_line, eq, src1, src2);
6409 6400
6410 if (kArchVariant >= kMips64r6) { 6401 if (kArchVariant >= kMips64r6) {
6411 max_d(dst, src1, src2); 6402 max_d(dst, src1, src2);
6412 } else { 6403 } else {
6413 Label return_left, return_right, done; 6404 Label return_left, return_right, done;
6414 6405
6415 c(OLT, D, src1, src2); 6406 BranchF64(&return_right, nullptr, lt, src1, src2);
6416 bc1t(&return_right); 6407 BranchF64(&return_left, nullptr, lt, src2, src1);
6417 nop();
6418
6419 c(OLT, D, src2, src1);
6420 bc1t(&return_left);
6421 nop();
6422 6408
6423 // Left equals right => check for -0. 6409 // Left equals right => check for -0.
6424 dmfc1(t8, src1); 6410 dmfc1(t8, src1);
6425 beq(t8, zero_reg, &return_left); 6411 Branch(&return_left, eq, t8, Operand(zero_reg));
6426 nop(); 6412 Branch(&return_right);
6427 b(&return_right);
6428 nop();
6429 6413
6430 bind(&return_right); 6414 bind(&return_right);
6431 if (!src2.is(dst)) { 6415 if (!src2.is(dst)) {
6432 Move_d(dst, src2); 6416 Move_d(dst, src2);
6433 } 6417 }
6434 b(&done); 6418 Branch(&done);
6435 nop();
6436 6419
6437 bind(&return_left); 6420 bind(&return_left);
6438 if (!src1.is(dst)) { 6421 if (!src1.is(dst)) {
6439 Move_d(dst, src1); 6422 Move_d(dst, src1);
6440 } 6423 }
6441 6424
6442 bind(&done); 6425 bind(&done);
6443 } 6426 }
6444 } 6427 }
6445 6428
6446 void MacroAssembler::Float64MaxOutOfLine(FPURegister dst, FPURegister src1, 6429 void MacroAssembler::Float64MaxOutOfLine(FPURegister dst, FPURegister src1,
6447 FPURegister src2) { 6430 FPURegister src2) {
6448 DCHECK(!src1.is(src2));
6449 add_d(dst, src1, src2); 6431 add_d(dst, src1, src2);
6450 } 6432 }
6451 6433
6452 void MacroAssembler::Float64Min(FPURegister dst, FPURegister src1, 6434 void MacroAssembler::Float64Min(FPURegister dst, FPURegister src1,
6453 FPURegister src2, Label* out_of_line) { 6435 FPURegister src2, Label* out_of_line) {
6454 DCHECK(!src1.is(src2)); 6436 if (src1.is(src2)) {
6437 Move_d(dst, src1);
6438 return;
6439 }
6455 6440
6456 // Check if one of operands is NaN. 6441 // Check if one of operands is NaN.
6457 BranchF64(nullptr, out_of_line, eq, src1, src2); 6442 BranchF64(nullptr, out_of_line, eq, src1, src2);
6458 6443
6459 if (kArchVariant >= kMips64r6) { 6444 if (kArchVariant >= kMips64r6) {
6460 min_d(dst, src1, src2); 6445 min_d(dst, src1, src2);
6461 } else { 6446 } else {
6462 Label return_left, return_right, done; 6447 Label return_left, return_right, done;
6463 6448
6464 c(OLT, D, src1, src2); 6449 BranchF64(&return_left, nullptr, lt, src1, src2);
6465 bc1t(&return_left); 6450 BranchF64(&return_right, nullptr, lt, src2, src1);
6466 nop();
6467
6468 c(OLT, D, src2, src1);
6469 bc1t(&return_right);
6470 nop();
6471 6451
6472 // Left equals right => check for -0. 6452 // Left equals right => check for -0.
6473 dmfc1(t8, src1); 6453 dmfc1(t8, src1);
6474 beq(t8, zero_reg, &return_right); 6454 Branch(&return_right, eq, t8, Operand(zero_reg));
6475 nop(); 6455 Branch(&return_left);
6476 b(&return_left);
6477 nop();
6478 6456
6479 bind(&return_right); 6457 bind(&return_right);
6480 if (!src2.is(dst)) { 6458 if (!src2.is(dst)) {
6481 Move_d(dst, src2); 6459 Move_d(dst, src2);
6482 } 6460 }
6483 b(&done); 6461 Branch(&done);
6484 nop();
6485 6462
6486 bind(&return_left); 6463 bind(&return_left);
6487 if (!src1.is(dst)) { 6464 if (!src1.is(dst)) {
6488 Move_d(dst, src1); 6465 Move_d(dst, src1);
6489 } 6466 }
6490 6467
6491 bind(&done); 6468 bind(&done);
6492 } 6469 }
6493 } 6470 }
6494 6471
6495 void MacroAssembler::Float64MinOutOfLine(FPURegister dst, FPURegister src1, 6472 void MacroAssembler::Float64MinOutOfLine(FPURegister dst, FPURegister src1,
6496 FPURegister src2) { 6473 FPURegister src2) {
6497 DCHECK(!src1.is(src2));
6498 add_d(dst, src1, src2); 6474 add_d(dst, src1, src2);
6499 } 6475 }
6500 6476
6501 void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte( 6477 void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte(
6502 Register first, Register second, Register scratch1, Register scratch2, 6478 Register first, Register second, Register scratch1, Register scratch2,
6503 Label* failure) { 6479 Label* failure) {
6504 const int kFlatOneByteStringMask = 6480 const int kFlatOneByteStringMask =
6505 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; 6481 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
6506 const int kFlatOneByteStringTag = 6482 const int kFlatOneByteStringTag =
6507 kStringTag | kOneByteStringTag | kSeqStringTag; 6483 kStringTag | kOneByteStringTag | kSeqStringTag;
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
7045 if (mag.shift > 0) sra(result, result, mag.shift); 7021 if (mag.shift > 0) sra(result, result, mag.shift);
7046 srl(at, dividend, 31); 7022 srl(at, dividend, 31);
7047 Addu(result, result, Operand(at)); 7023 Addu(result, result, Operand(at));
7048 } 7024 }
7049 7025
7050 7026
7051 } // namespace internal 7027 } // namespace internal
7052 } // namespace v8 7028 } // namespace v8
7053 7029
7054 #endif // V8_TARGET_ARCH_MIPS64 7030 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | test/cctest/test-macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698