| 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;
|
| }
|
|
|