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

Unified Diff: src/compiler/mips64/code-generator-mips64.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/mips64/code-generator-mips64.cc
diff --git a/src/compiler/mips64/code-generator-mips64.cc b/src/compiler/mips64/code-generator-mips64.cc
index 053434eec9a916f4e9eb287ffbb712002d70fc85..7ccf0a774c5e5d548534fbddf4cca54c5ce4b6c4 100644
--- a/src/compiler/mips64/code-generator-mips64.cc
+++ b/src/compiler/mips64/code-generator-mips64.cc
@@ -1046,19 +1046,10 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
if (instr->arch_opcode() == kMips64Tst) {
cc = FlagsConditionToConditionTst(condition);
__ And(kScratchReg, i.InputRegister(0), i.InputOperand(1));
- __ xori(result, zero_reg, 1); // Create 1 for true.
- if (kArchVariant == kMips64r6) {
- 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() == kMips64Dadd ||
@@ -1078,20 +1069,18 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
case ne: {
Register left = i.InputRegister(0);
Operand right = i.InputOperand(1);
- __ Dsubu(kScratchReg, left, right);
- __ xori(result, zero_reg, 1);
- if (kArchVariant == kMips64r6) {
- 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);
- }
+ __ Dsubu(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:

Powered by Google App Engine
This is Rietveld 408576698