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

Side by Side Diff: src/mips/macro-assembler-mips.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/compiler/mips64/code-generator-mips64.cc ('k') | src/mips64/macro-assembler-mips64.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_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/division-by-constant.h" 10 #include "src/base/division-by-constant.h"
(...skipping 5861 matching lines...) Expand 10 before | Expand all | Expand 10 after
5872 // Check that neither is a smi. 5872 // Check that neither is a smi.
5873 STATIC_ASSERT(kSmiTag == 0); 5873 STATIC_ASSERT(kSmiTag == 0);
5874 And(scratch1, first, Operand(second)); 5874 And(scratch1, first, Operand(second));
5875 JumpIfSmi(scratch1, failure); 5875 JumpIfSmi(scratch1, failure);
5876 JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1, 5876 JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1,
5877 scratch2, failure); 5877 scratch2, failure);
5878 } 5878 }
5879 5879
5880 void MacroAssembler::Float32Max(FPURegister dst, FPURegister src1, 5880 void MacroAssembler::Float32Max(FPURegister dst, FPURegister src1,
5881 FPURegister src2, Label* out_of_line) { 5881 FPURegister src2, Label* out_of_line) {
5882 DCHECK(!src1.is(src2)); 5882 if (src1.is(src2)) {
5883 Move_s(dst, src1);
5884 return;
5885 }
5883 5886
5884 // Check if one of operands is NaN. 5887 // Check if one of operands is NaN.
5885 BranchF32(nullptr, out_of_line, eq, src1, src2); 5888 BranchF32(nullptr, out_of_line, eq, src1, src2);
5886 5889
5887 if (IsMipsArchVariant(kMips32r6)) { 5890 if (IsMipsArchVariant(kMips32r6)) {
5888 max_s(dst, src1, src2); 5891 max_s(dst, src1, src2);
5889 } else { 5892 } else {
5890 Label return_left, return_right, done; 5893 Label return_left, return_right, done;
5891 5894
5892 c(OLT, S, src1, src2); 5895 BranchF32(&return_right, nullptr, lt, src1, src2);
5893 bc1t(&return_right); 5896 BranchF32(&return_left, nullptr, lt, src2, src1);
5894 nop();
5895
5896 c(OLT, S, src2, src1);
5897 bc1t(&return_left);
5898 nop();
5899 5897
5900 // Operands are equal, but check for +/-0. 5898 // Operands are equal, but check for +/-0.
5901 mfc1(t8, src1); 5899 mfc1(t8, src1);
5902 beq(t8, zero_reg, &return_left); 5900 Branch(&return_left, eq, t8, Operand(zero_reg));
5903 nop(); 5901 Branch(&return_right);
5904 b(&return_right);
5905 nop();
5906 5902
5907 bind(&return_right); 5903 bind(&return_right);
5908 if (!src2.is(dst)) { 5904 if (!src2.is(dst)) {
5909 Move_s(dst, src2); 5905 Move_s(dst, src2);
5910 } 5906 }
5911 b(&done); 5907 Branch(&done);
5912 nop();
5913 5908
5914 bind(&return_left); 5909 bind(&return_left);
5915 if (!src1.is(dst)) { 5910 if (!src1.is(dst)) {
5916 Move_s(dst, src1); 5911 Move_s(dst, src1);
5917 } 5912 }
5918 5913
5919 bind(&done); 5914 bind(&done);
5920 } 5915 }
5921 } 5916 }
5922 5917
5923 void MacroAssembler::Float32MaxOutOfLine(FPURegister dst, FPURegister src1, 5918 void MacroAssembler::Float32MaxOutOfLine(FPURegister dst, FPURegister src1,
5924 FPURegister src2) { 5919 FPURegister src2) {
5925 DCHECK(!src1.is(src2));
5926 add_s(dst, src1, src2); 5920 add_s(dst, src1, src2);
5927 } 5921 }
5928 5922
5929 void MacroAssembler::Float32Min(FPURegister dst, FPURegister src1, 5923 void MacroAssembler::Float32Min(FPURegister dst, FPURegister src1,
5930 FPURegister src2, Label* out_of_line) { 5924 FPURegister src2, Label* out_of_line) {
5931 DCHECK(!src1.is(src2)); 5925 if (src1.is(src2)) {
5926 Move_s(dst, src1);
5927 return;
5928 }
5932 5929
5933 // Check if one of operands is NaN. 5930 // Check if one of operands is NaN.
5934 BranchF32(nullptr, out_of_line, eq, src1, src2); 5931 BranchF32(nullptr, out_of_line, eq, src1, src2);
5935 5932
5936 if (IsMipsArchVariant(kMips32r6)) { 5933 if (IsMipsArchVariant(kMips32r6)) {
5937 min_s(dst, src1, src2); 5934 min_s(dst, src1, src2);
5938 } else { 5935 } else {
5939 Label return_left, return_right, done; 5936 Label return_left, return_right, done;
5940 5937
5941 c(OLT, S, src1, src2); 5938 BranchF32(&return_left, nullptr, lt, src1, src2);
5942 bc1t(&return_left); 5939 BranchF32(&return_right, nullptr, lt, src2, src1);
5943 nop();
5944
5945 c(OLT, S, src2, src1);
5946 bc1t(&return_right);
5947 nop();
5948 5940
5949 // Left equals right => check for -0. 5941 // Left equals right => check for -0.
5950 mfc1(t8, src1); 5942 mfc1(t8, src1);
5951 beq(t8, zero_reg, &return_right); 5943 Branch(&return_right, eq, t8, Operand(zero_reg));
5952 nop(); 5944 Branch(&return_left);
5953 b(&return_left);
5954 nop();
5955 5945
5956 bind(&return_right); 5946 bind(&return_right);
5957 if (!src2.is(dst)) { 5947 if (!src2.is(dst)) {
5958 Move_s(dst, src2); 5948 Move_s(dst, src2);
5959 } 5949 }
5960 b(&done); 5950 Branch(&done);
5961 nop();
5962 5951
5963 bind(&return_left); 5952 bind(&return_left);
5964 if (!src1.is(dst)) { 5953 if (!src1.is(dst)) {
5965 Move_s(dst, src1); 5954 Move_s(dst, src1);
5966 } 5955 }
5967 5956
5968 bind(&done); 5957 bind(&done);
5969 } 5958 }
5970 } 5959 }
5971 5960
5972 void MacroAssembler::Float32MinOutOfLine(FPURegister dst, FPURegister src1, 5961 void MacroAssembler::Float32MinOutOfLine(FPURegister dst, FPURegister src1,
5973 FPURegister src2) { 5962 FPURegister src2) {
5974 DCHECK(!src1.is(src2));
5975 add_s(dst, src1, src2); 5963 add_s(dst, src1, src2);
5976 } 5964 }
5977 5965
5978 void MacroAssembler::Float64Max(DoubleRegister dst, DoubleRegister src1, 5966 void MacroAssembler::Float64Max(DoubleRegister dst, DoubleRegister src1,
5979 DoubleRegister src2, Label* out_of_line) { 5967 DoubleRegister src2, Label* out_of_line) {
5980 DCHECK(!src1.is(src2)); 5968 if (src1.is(src2)) {
5969 Move_d(dst, src1);
5970 return;
5971 }
5981 5972
5982 // Check if one of operands is NaN. 5973 // Check if one of operands is NaN.
5983 BranchF64(nullptr, out_of_line, eq, src1, src2); 5974 BranchF64(nullptr, out_of_line, eq, src1, src2);
5984 5975
5985 if (IsMipsArchVariant(kMips32r6)) { 5976 if (IsMipsArchVariant(kMips32r6)) {
5986 max_d(dst, src1, src2); 5977 max_d(dst, src1, src2);
5987 } else { 5978 } else {
5988 Label return_left, return_right, done; 5979 Label return_left, return_right, done;
5989 5980
5990 c(OLT, D, src1, src2); 5981 BranchF64(&return_right, nullptr, lt, src1, src2);
5991 bc1t(&return_right); 5982 BranchF64(&return_left, nullptr, lt, src2, src1);
5992 nop();
5993
5994 c(OLT, D, src2, src1);
5995 bc1t(&return_left);
5996 nop();
5997 5983
5998 // Left equals right => check for -0. 5984 // Left equals right => check for -0.
5999 Mfhc1(t8, src1); 5985 Mfhc1(t8, src1);
6000 beq(t8, zero_reg, &return_left); 5986 Branch(&return_left, eq, t8, Operand(zero_reg));
6001 nop(); 5987 Branch(&return_right);
6002 b(&return_right);
6003 nop();
6004 5988
6005 bind(&return_right); 5989 bind(&return_right);
6006 if (!src2.is(dst)) { 5990 if (!src2.is(dst)) {
6007 Move_d(dst, src2); 5991 Move_d(dst, src2);
6008 } 5992 }
6009 b(&done); 5993 Branch(&done);
6010 nop();
6011 5994
6012 bind(&return_left); 5995 bind(&return_left);
6013 if (!src1.is(dst)) { 5996 if (!src1.is(dst)) {
6014 Move_d(dst, src1); 5997 Move_d(dst, src1);
6015 } 5998 }
6016 5999
6017 bind(&done); 6000 bind(&done);
6018 } 6001 }
6019 } 6002 }
6020 6003
6021 void MacroAssembler::Float64MaxOutOfLine(DoubleRegister dst, 6004 void MacroAssembler::Float64MaxOutOfLine(DoubleRegister dst,
6022 DoubleRegister src1, 6005 DoubleRegister src1,
6023 DoubleRegister src2) { 6006 DoubleRegister src2) {
6024 DCHECK(!src1.is(src2));
6025 add_d(dst, src1, src2); 6007 add_d(dst, src1, src2);
6026 } 6008 }
6027 6009
6028 void MacroAssembler::Float64Min(DoubleRegister dst, DoubleRegister src1, 6010 void MacroAssembler::Float64Min(DoubleRegister dst, DoubleRegister src1,
6029 DoubleRegister src2, Label* out_of_line) { 6011 DoubleRegister src2, Label* out_of_line) {
6030 DCHECK(!src1.is(src2)); 6012 if (src1.is(src2)) {
6013 Move_d(dst, src1);
6014 return;
6015 }
6031 6016
6032 // Check if one of operands is NaN. 6017 // Check if one of operands is NaN.
6033 BranchF64(nullptr, out_of_line, eq, src1, src2); 6018 BranchF64(nullptr, out_of_line, eq, src1, src2);
6034 6019
6035 if (IsMipsArchVariant(kMips32r6)) { 6020 if (IsMipsArchVariant(kMips32r6)) {
6036 min_d(dst, src1, src2); 6021 min_d(dst, src1, src2);
6037 } else { 6022 } else {
6038 Label return_left, return_right, done; 6023 Label return_left, return_right, done;
6039 6024
6040 c(OLT, D, src1, src2); 6025 BranchF64(&return_left, nullptr, lt, src1, src2);
6041 bc1t(&return_left); 6026 BranchF64(&return_right, nullptr, lt, src2, src1);
6042 nop();
6043
6044 c(OLT, D, src2, src1);
6045 bc1t(&return_right);
6046 nop();
6047 6027
6048 // Left equals right => check for -0. 6028 // Left equals right => check for -0.
6049 Mfhc1(t8, src1); 6029 Mfhc1(t8, src1);
6050 beq(t8, zero_reg, &return_right); 6030 Branch(&return_right, eq, t8, Operand(zero_reg));
6051 nop(); 6031 Branch(&return_left);
6052 b(&return_left);
6053 nop();
6054 6032
6055 bind(&return_right); 6033 bind(&return_right);
6056 if (!src2.is(dst)) { 6034 if (!src2.is(dst)) {
6057 Move_d(dst, src2); 6035 Move_d(dst, src2);
6058 } 6036 }
6059 b(&done); 6037 Branch(&done);
6060 nop();
6061 6038
6062 bind(&return_left); 6039 bind(&return_left);
6063 if (!src1.is(dst)) { 6040 if (!src1.is(dst)) {
6064 Move_d(dst, src1); 6041 Move_d(dst, src1);
6065 } 6042 }
6066 6043
6067 bind(&done); 6044 bind(&done);
6068 } 6045 }
6069 } 6046 }
6070 6047
6071 void MacroAssembler::Float64MinOutOfLine(DoubleRegister dst, 6048 void MacroAssembler::Float64MinOutOfLine(DoubleRegister dst,
6072 DoubleRegister src1, 6049 DoubleRegister src1,
6073 DoubleRegister src2) { 6050 DoubleRegister src2) {
6074 DCHECK(!src1.is(src2));
6075 add_d(dst, src1, src2); 6051 add_d(dst, src1, src2);
6076 } 6052 }
6077 6053
6078 void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte( 6054 void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte(
6079 Register first, Register second, Register scratch1, Register scratch2, 6055 Register first, Register second, Register scratch1, Register scratch2,
6080 Label* failure) { 6056 Label* failure) {
6081 const int kFlatOneByteStringMask = 6057 const int kFlatOneByteStringMask =
6082 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; 6058 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
6083 const int kFlatOneByteStringTag = 6059 const int kFlatOneByteStringTag =
6084 kStringTag | kOneByteStringTag | kSeqStringTag; 6060 kStringTag | kOneByteStringTag | kSeqStringTag;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
6626 if (mag.shift > 0) sra(result, result, mag.shift); 6602 if (mag.shift > 0) sra(result, result, mag.shift);
6627 srl(at, dividend, 31); 6603 srl(at, dividend, 31);
6628 Addu(result, result, Operand(at)); 6604 Addu(result, result, Operand(at));
6629 } 6605 }
6630 6606
6631 6607
6632 } // namespace internal 6608 } // namespace internal
6633 } // namespace v8 6609 } // namespace v8
6634 6610
6635 #endif // V8_TARGET_ARCH_MIPS 6611 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/compiler/mips64/code-generator-mips64.cc ('k') | src/mips64/macro-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698