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

Unified Diff: src/compiler/arm64/instruction-selector-arm64.cc

Issue 697653002: [turbofan] Select tbz/tbnz when possible on ARM64. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/arm64/instruction-selector-arm64.cc
diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc
index 39cd6ca77e0cc31b1a50c4d4a4ed53cf0ebd672c..51eb3533ec9442923755f0fb76eb5c4df5ae4ada 100644
--- a/src/compiler/arm64/instruction-selector-arm64.cc
+++ b/src/compiler/arm64/instruction-selector-arm64.cc
@@ -1194,12 +1194,44 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
case IrOpcode::kInt32Sub:
return VisitWordCompare(this, value, kArm64Cmp32, &cont, false,
kArithmeticImm);
- case IrOpcode::kWord32And:
+ case IrOpcode::kWord32And: {
+ Int32BinopMatcher m(value);
+ if (m.right().HasValue() &&
+ (base::bits::CountPopulation32(m.right().Value()) == 1)) {
+ // If the mask has only one bit set, we can use tbz/tbnz.
+ DCHECK((cont.condition() == kEqual) ||
+ (cont.condition() == kNotEqual));
+ ArchOpcode opcode =
+ (cont.condition() == kEqual) ? kArm64Tbz32 : kArm64Tbnz32;
+ Emit(opcode, NULL, g.UseRegister(m.left().node()),
+ g.TempImmediate(
+ base::bits::CountTrailingZeros32(m.right().Value())),
+ g.Label(cont.true_block()),
+ g.Label(cont.false_block()))->MarkAsControl();
+ return;
+ }
return VisitWordCompare(this, value, kArm64Tst32, &cont, true,
kLogical32Imm);
- case IrOpcode::kWord64And:
+ }
+ case IrOpcode::kWord64And: {
+ Int64BinopMatcher m(value);
+ if (m.right().HasValue() &&
+ (base::bits::CountPopulation64(m.right().Value()) == 1)) {
+ // If the mask has only one bit set, we can use tbz/tbnz.
+ DCHECK((cont.condition() == kEqual) ||
+ (cont.condition() == kNotEqual));
+ ArchOpcode opcode =
+ (cont.condition() == kEqual) ? kArm64Tbz : kArm64Tbnz;
+ Emit(opcode, NULL, g.UseRegister(m.left().node()),
+ g.TempImmediate(
+ base::bits::CountTrailingZeros64(m.right().Value())),
+ g.Label(cont.true_block()),
+ g.Label(cont.false_block()))->MarkAsControl();
+ return;
+ }
return VisitWordCompare(this, value, kArm64Tst, &cont, true,
kLogical64Imm);
+ }
default:
break;
}
« no previous file with comments | « src/compiler/arm64/instruction-codes-arm64.h ('k') | test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698