Commit 3556d250 authored by Pierre Langlois's avatar Pierre Langlois Committed by Commit Bot

[arm64] Use CBZ in binary switch.

When comparing with zero, we can generate a CBZ instruction instead of a
CMP+B. If we teach TurboAssembler::JumpIfEqual() to do it then we can do it
in code generated for binary switches.

Change-Id: I39a045ed666fd6569bf9c9f6be28c4efbeeb01a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1836254Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Pierre Langlois <pierre.langlois@arm.com>
Cr-Commit-Position: refs/heads/master@{#64094}
parent e92e9151
...@@ -1055,13 +1055,11 @@ void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, ...@@ -1055,13 +1055,11 @@ void TurboAssembler::JumpIfSmi(Register value, Label* smi_label,
} }
void TurboAssembler::JumpIfEqual(Register x, int32_t y, Label* dest) { void TurboAssembler::JumpIfEqual(Register x, int32_t y, Label* dest) {
Cmp(x, y); CompareAndBranch(x, y, eq, dest);
B(eq, dest);
} }
void TurboAssembler::JumpIfLessThan(Register x, int32_t y, Label* dest) { void TurboAssembler::JumpIfLessThan(Register x, int32_t y, Label* dest) {
Cmp(x, y); CompareAndBranch(x, y, lt, dest);
B(lt, dest);
} }
void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label) { void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label) {
...@@ -1201,7 +1199,7 @@ void TurboAssembler::DropSlots(int64_t count) { ...@@ -1201,7 +1199,7 @@ void TurboAssembler::DropSlots(int64_t count) {
void TurboAssembler::PushArgument(const Register& arg) { Push(padreg, arg); } void TurboAssembler::PushArgument(const Register& arg) { Push(padreg, arg); }
void MacroAssembler::CompareAndBranch(const Register& lhs, const Operand& rhs, void TurboAssembler::CompareAndBranch(const Register& lhs, const Operand& rhs,
Condition cond, Label* label) { Condition cond, Label* label) {
if (rhs.IsImmediate() && (rhs.ImmediateValue() == 0) && if (rhs.IsImmediate() && (rhs.ImmediateValue() == 0) &&
((cond == eq) || (cond == ne))) { ((cond == eq) || (cond == ne))) {
...@@ -1216,7 +1214,7 @@ void MacroAssembler::CompareAndBranch(const Register& lhs, const Operand& rhs, ...@@ -1216,7 +1214,7 @@ void MacroAssembler::CompareAndBranch(const Register& lhs, const Operand& rhs,
} }
} }
void MacroAssembler::CompareTaggedAndBranch(const Register& lhs, void TurboAssembler::CompareTaggedAndBranch(const Register& lhs,
const Operand& rhs, Condition cond, const Operand& rhs, Condition cond,
Label* label) { Label* label) {
if (COMPRESS_POINTERS_BOOL) { if (COMPRESS_POINTERS_BOOL) {
......
...@@ -844,6 +844,13 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -844,6 +844,13 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CheckPageFlag(const Register& object, int mask, Condition cc, void CheckPageFlag(const Register& object, int mask, Condition cc,
Label* condition_met); Label* condition_met);
// Compare a register with an operand, and branch to label depending on the
// condition. May corrupt the status flags.
inline void CompareAndBranch(const Register& lhs, const Operand& rhs,
Condition cond, Label* label);
inline void CompareTaggedAndBranch(const Register& lhs, const Operand& rhs,
Condition cond, Label* label);
// Test the bits of register defined by bit_pattern, and branch if ANY of // Test the bits of register defined by bit_pattern, and branch if ANY of
// those bits are set. May corrupt the status flags. // those bits are set. May corrupt the status flags.
inline void TestAndBranchIfAnySet(const Register& reg, inline void TestAndBranchIfAnySet(const Register& reg,
...@@ -1644,13 +1651,6 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { ...@@ -1644,13 +1651,6 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// be aligned to 16 bytes. // be aligned to 16 bytes.
void PeekPair(const CPURegister& dst1, const CPURegister& dst2, int offset); void PeekPair(const CPURegister& dst1, const CPURegister& dst2, int offset);
// Compare a register with an operand, and branch to label depending on the
// condition. May corrupt the status flags.
inline void CompareAndBranch(const Register& lhs, const Operand& rhs,
Condition cond, Label* label);
inline void CompareTaggedAndBranch(const Register& lhs, const Operand& rhs,
Condition cond, Label* label);
// Insert one or more instructions into the instruction stream that encode // Insert one or more instructions into the instruction stream that encode
// some caller-defined data. The instructions used will be executable with no // some caller-defined data. The instructions used will be executable with no
// side effects. // side effects.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment