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

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

Issue 2477453005: MIPS[64]: Optimize kMips[64]Tst in code-generator-mips[64].cc (Closed)
Patch Set: Address code review remarks Created 4 years, 1 month 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/compilation-info.h" 6 #include "src/compilation-info.h"
7 #include "src/compiler/code-generator-impl.h" 7 #include "src/compiler/code-generator-impl.h"
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/osr.h" 10 #include "src/compiler/osr.h"
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 Label false_value; 2019 Label false_value;
2020 DCHECK_NE(0u, instr->OutputCount()); 2020 DCHECK_NE(0u, instr->OutputCount());
2021 Register result = i.OutputRegister(instr->OutputCount() - 1); 2021 Register result = i.OutputRegister(instr->OutputCount() - 1);
2022 Condition cc = kNoCondition; 2022 Condition cc = kNoCondition;
2023 // MIPS does not have condition code flags, so compare and branch are 2023 // MIPS does not have condition code flags, so compare and branch are
2024 // implemented differently than on the other arch's. The compare operations 2024 // implemented differently than on the other arch's. The compare operations
2025 // emit mips pseudo-instructions, which are checked and handled here. 2025 // emit mips pseudo-instructions, which are checked and handled here.
2026 2026
2027 if (instr->arch_opcode() == kMips64Tst) { 2027 if (instr->arch_opcode() == kMips64Tst) {
2028 cc = FlagsConditionToConditionTst(condition); 2028 cc = FlagsConditionToConditionTst(condition);
2029 __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); 2029 if (instr->InputAt(1)->IsImmediate() &&
2030 __ Sltu(result, zero_reg, kScratchReg); 2030 base::bits::IsPowerOfTwo64(i.InputOperand(1).immediate())) {
2031 uint16_t pos =
2032 base::bits::CountTrailingZeros64(i.InputOperand(1).immediate());
2033 __ ExtractBits(result, i.InputRegister(0), pos, 1);
2034 } else {
2035 __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1));
2036 __ Sltu(result, zero_reg, kScratchReg);
2037 }
2031 if (cc == eq) { 2038 if (cc == eq) {
2032 // Sltu produces 0 for equality, invert the result. 2039 // Sltu produces 0 for equality, invert the result.
2033 __ xori(result, result, 1); 2040 __ xori(result, result, 1);
2034 } 2041 }
2035 return; 2042 return;
2036 } else if (instr->arch_opcode() == kMips64Dadd || 2043 } else if (instr->arch_opcode() == kMips64Dadd ||
2037 instr->arch_opcode() == kMips64Dsub) { 2044 instr->arch_opcode() == kMips64Dsub) {
2038 cc = FlagsConditionToConditionOvf(condition); 2045 cc = FlagsConditionToConditionOvf(condition);
2039 // Check for overflow creates 1 or 0 for result. 2046 // Check for overflow creates 1 or 0 for result.
2040 __ dsrl32(kScratchReg, i.OutputRegister(), 31); 2047 __ dsrl32(kScratchReg, i.OutputRegister(), 31);
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 padding_size -= v8::internal::Assembler::kInstrSize; 2550 padding_size -= v8::internal::Assembler::kInstrSize;
2544 } 2551 }
2545 } 2552 }
2546 } 2553 }
2547 2554
2548 #undef __ 2555 #undef __
2549 2556
2550 } // namespace compiler 2557 } // namespace compiler
2551 } // namespace internal 2558 } // namespace internal
2552 } // namespace v8 2559 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698