Bug 1678049 - Use CBZ/CBNZ on ARM64 also for branchTest. r=nbp

The branchTest primitives can use CBZ/CBNZ just as easily as the branch primitives can.

Differential Revision: https://phabricator.services.mozilla.com/D97477
This commit is contained in:
Lars T Hansen 2020-11-19 19:55:29 +00:00
Родитель 1df6e0e75f
Коммит da463afc21
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -1208,14 +1208,18 @@ void MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs,
L label) {
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed ||
cond == NotSigned);
// x86 prefers |test foo, foo| to |cmp foo, #0|.
// Convert the former to the latter for ARM.
if (lhs == rhs && (cond == Zero || cond == NonZero)) {
cmp32(lhs, Imm32(0));
// The x86-biased front end prefers |test foo, foo| to |cmp foo, #0|, but
// the latter is better on ARM64.
if (cond == Zero) {
Cbz(ARMRegister(lhs, 32), label);
} else {
Cbnz(ARMRegister(lhs, 32), label);
}
} else {
test32(lhs, rhs);
B(label, cond);
}
B(label, cond);
}
template <class L>