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

Side by Side Diff: src/compiler/mips64/code-generator-mips64.cc

Issue 1408033003: MIPS: [turbofan] Optimize fpu compares with zero literal. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 #include "src/compiler/code-generator-impl.h" 6 #include "src/compiler/code-generator-impl.h"
7 #include "src/compiler/gap-resolver.h" 7 #include "src/compiler/gap-resolver.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/osr.h" 9 #include "src/compiler/osr.h"
10 #include "src/mips/macro-assembler-mips.h" 10 #include "src/mips/macro-assembler-mips.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 FloatRegister InputSingleRegister(size_t index) { 46 FloatRegister InputSingleRegister(size_t index) {
47 return ToSingleRegister(instr_->InputAt(index)); 47 return ToSingleRegister(instr_->InputAt(index));
48 } 48 }
49 49
50 FloatRegister ToSingleRegister(InstructionOperand* op) { 50 FloatRegister ToSingleRegister(InstructionOperand* op) {
51 // Single (Float) and Double register namespace is same on MIPS, 51 // Single (Float) and Double register namespace is same on MIPS,
52 // both are typedefs of FPURegister. 52 // both are typedefs of FPURegister.
53 return ToDoubleRegister(op); 53 return ToDoubleRegister(op);
54 } 54 }
55 55
56 DoubleRegister InputOrZeroDoubleRegister(size_t index) {
57 if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero;
58
59 return InputDoubleRegister(index);
60 }
61
62 DoubleRegister InputOrZeroSingleRegister(size_t index) {
63 if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero;
64
65 return InputSingleRegister(index);
66 }
67
56 Operand InputImmediate(size_t index) { 68 Operand InputImmediate(size_t index) {
57 Constant constant = ToConstant(instr_->InputAt(index)); 69 Constant constant = ToConstant(instr_->InputAt(index));
58 switch (constant.type()) { 70 switch (constant.type()) {
59 case Constant::kInt32: 71 case Constant::kInt32:
60 return Operand(constant.ToInt32()); 72 return Operand(constant.ToInt32());
61 case Constant::kInt64: 73 case Constant::kInt64:
62 return Operand(constant.ToInt64()); 74 return Operand(constant.ToInt64());
63 case Constant::kFloat32: 75 case Constant::kFloat32:
64 return Operand( 76 return Operand(
65 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED)); 77 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED));
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 __ dsra32(kScratchReg, i.OutputRegister(), 0); 1010 __ dsra32(kScratchReg, i.OutputRegister(), 0);
999 __ sra(at, i.OutputRegister(), 31); 1011 __ sra(at, i.OutputRegister(), 31);
1000 __ Branch(tlabel, cc, at, Operand(kScratchReg)); 1012 __ Branch(tlabel, cc, at, Operand(kScratchReg));
1001 } else if (instr->arch_opcode() == kMips64Cmp) { 1013 } else if (instr->arch_opcode() == kMips64Cmp) {
1002 cc = FlagsConditionToConditionCmp(branch->condition); 1014 cc = FlagsConditionToConditionCmp(branch->condition);
1003 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); 1015 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1));
1004 } else if (instr->arch_opcode() == kMips64CmpS) { 1016 } else if (instr->arch_opcode() == kMips64CmpS) {
1005 if (!convertCondition(branch->condition, cc)) { 1017 if (!convertCondition(branch->condition, cc)) {
1006 UNSUPPORTED_COND(kMips64CmpS, branch->condition); 1018 UNSUPPORTED_COND(kMips64CmpS, branch->condition);
1007 } 1019 }
1008 __ BranchF32(tlabel, NULL, cc, i.InputSingleRegister(0), 1020 FPURegister left = i.InputOrZeroSingleRegister(0);
1009 i.InputSingleRegister(1)); 1021 FPURegister right = i.InputOrZeroSingleRegister(1);
1022 if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) &&
1023 !__ IsDoubleZeroRegSet()) {
1024 __ Move(kDoubleRegZero, 0.0);
1025 }
1026 __ BranchF32(tlabel, NULL, cc, left, right);
1010 } else if (instr->arch_opcode() == kMips64CmpD) { 1027 } else if (instr->arch_opcode() == kMips64CmpD) {
1011 if (!convertCondition(branch->condition, cc)) { 1028 if (!convertCondition(branch->condition, cc)) {
1012 UNSUPPORTED_COND(kMips64CmpD, branch->condition); 1029 UNSUPPORTED_COND(kMips64CmpD, branch->condition);
1013 } 1030 }
1014 __ BranchF64(tlabel, NULL, cc, i.InputDoubleRegister(0), 1031 FPURegister left = i.InputOrZeroDoubleRegister(0);
1015 i.InputDoubleRegister(1)); 1032 FPURegister right = i.InputOrZeroDoubleRegister(1);
1033 if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) &&
1034 !__ IsDoubleZeroRegSet()) {
1035 __ Move(kDoubleRegZero, 0.0);
1036 }
1037 __ BranchF64(tlabel, NULL, cc, left, right);
1016 } else { 1038 } else {
1017 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", 1039 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n",
1018 instr->arch_opcode()); 1040 instr->arch_opcode());
1019 UNIMPLEMENTED(); 1041 UNIMPLEMENTED();
1020 } 1042 }
1021 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. 1043 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel.
1022 } 1044 }
1023 1045
1024 1046
1025 void CodeGenerator::AssembleArchJump(RpoNumber target) { 1047 void CodeGenerator::AssembleArchJump(RpoNumber target) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 if (cc == ls) { 1140 if (cc == ls) {
1119 __ xori(result, result, 1); 1141 __ xori(result, result, 1);
1120 } 1142 }
1121 } break; 1143 } break;
1122 default: 1144 default:
1123 UNREACHABLE(); 1145 UNREACHABLE();
1124 } 1146 }
1125 return; 1147 return;
1126 } else if (instr->arch_opcode() == kMips64CmpD || 1148 } else if (instr->arch_opcode() == kMips64CmpD ||
1127 instr->arch_opcode() == kMips64CmpS) { 1149 instr->arch_opcode() == kMips64CmpS) {
1128 FPURegister left = i.InputDoubleRegister(0); 1150 FPURegister left = i.InputOrZeroDoubleRegister(0);
1129 FPURegister right = i.InputDoubleRegister(1); 1151 FPURegister right = i.InputOrZeroDoubleRegister(1);
1152 if ((left.is(kDoubleRegZero) || right.is(kDoubleRegZero)) &&
1153 !__ IsDoubleZeroRegSet()) {
1154 __ Move(kDoubleRegZero, 0.0);
1155 }
1130 bool predicate; 1156 bool predicate;
1131 FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition); 1157 FPUCondition cc = FlagsConditionToConditionCmpFPU(predicate, condition);
1132 if (kArchVariant != kMips64r6) { 1158 if (kArchVariant != kMips64r6) {
1133 __ li(result, Operand(1)); 1159 __ li(result, Operand(1));
1134 if (instr->arch_opcode() == kMips64CmpD) { 1160 if (instr->arch_opcode() == kMips64CmpD) {
1135 __ c(cc, D, left, right); 1161 __ c(cc, D, left, right);
1136 } else { 1162 } else {
1137 DCHECK(instr->arch_opcode() == kMips64CmpS); 1163 DCHECK(instr->arch_opcode() == kMips64CmpS);
1138 __ c(cc, S, left, right); 1164 __ c(cc, S, left, right);
1139 } 1165 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 padding_size -= v8::internal::Assembler::kInstrSize; 1536 padding_size -= v8::internal::Assembler::kInstrSize;
1511 } 1537 }
1512 } 1538 }
1513 } 1539 }
1514 1540
1515 #undef __ 1541 #undef __
1516 1542
1517 } // namespace compiler 1543 } // namespace compiler
1518 } // namespace internal 1544 } // namespace internal
1519 } // namespace v8 1545 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/mips/instruction-selector-mips.cc ('k') | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698