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

Unified Diff: src/compiler/mips/code-generator-mips.cc

Issue 1400833002: MIPS: [turbofan] Improve test and equality compare with zero and constants. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo. 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/mips/code-generator-mips.cc
diff --git a/src/compiler/mips/code-generator-mips.cc b/src/compiler/mips/code-generator-mips.cc
index 7769b9e739ec5873e47b32a0e9060082e7350e5e..d6d5ac5b2097b9142c9196bc578402bb85c9c75a 100644
--- a/src/compiler/mips/code-generator-mips.cc
+++ b/src/compiler/mips/code-generator-mips.cc
@@ -968,19 +968,10 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
if (instr->arch_opcode() == kMipsTst) {
cc = FlagsConditionToConditionTst(condition);
__ And(kScratchReg, i.InputRegister(0), i.InputOperand(1));
- __ xori(result, zero_reg, 1); // Create 1 for true.
- if (IsMipsArchVariant(kMips32r6)) {
- if (cc == eq) {
- __ seleqz(result, result, kScratchReg);
- } else {
- __ selnez(result, result, kScratchReg);
- }
- } else {
- if (cc == eq) {
- __ Movn(result, zero_reg, kScratchReg);
- } else {
- __ Movz(result, zero_reg, kScratchReg);
- }
+ __ Sltu(result, zero_reg, kScratchReg);
+ if (cc == eq) {
+ // Sltu produces 0 for equality, invert the result.
+ __ xori(result, result, 1);
}
return;
} else if (instr->arch_opcode() == kMipsAddOvf ||
@@ -999,20 +990,18 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
case ne: {
Register left = i.InputRegister(0);
Operand right = i.InputOperand(1);
- __ Subu(kScratchReg, left, right);
- __ xori(result, zero_reg, 1);
- if (IsMipsArchVariant(kMips32r6)) {
- if (cc == eq) {
- __ seleqz(result, result, kScratchReg);
- } else {
- __ selnez(result, result, kScratchReg);
- }
+ Register select;
+ if (instr->InputAt(1)->IsImmediate() && right.immediate() == 0) {
+ // Pass left operand if right is zero.
+ select = left;
} else {
- if (cc == eq) {
- __ Movn(result, zero_reg, kScratchReg);
- } else {
- __ Movz(result, zero_reg, kScratchReg);
- }
+ __ Subu(kScratchReg, left, right);
+ select = kScratchReg;
+ }
+ __ Sltu(result, zero_reg, select);
+ if (cc == eq) {
+ // Sltu produces 0 for equality, invert the result.
+ __ xori(result, result, 1);
}
} break;
case lt:
« no previous file with comments | « no previous file | src/compiler/mips/instruction-selector-mips.cc » ('j') | src/compiler/mips/instruction-selector-mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698