Commit 7aeafdee authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[x64] Avoid movl before table jump when possible

If the input to a Switch happens to be something that we already know to
be zero-extended, then we don't need to emit a movl to zero-extend it.
This is a tiny optimization, but speeds up the Mono interpreter by 3%
because it's heavily dependent on switch dispatch speed.

Bug: v8:10606
Change-Id: I67ab6b6aeb93df4e420ea2afef41a2234d7da979
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2368195Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#69523}
parent 24e79516
......@@ -2271,7 +2271,12 @@ void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) {
value_operand, g.TempImmediate(-sw.min_value()));
} else {
// Zero extend, because we use it as 64-bit index into the jump table.
Emit(kX64Movl, index_operand, value_operand);
if (ZeroExtendsWord32ToWord64(node->InputAt(0))) {
// Input value has already been zero-extended.
index_operand = value_operand;
} else {
Emit(kX64Movl, index_operand, value_operand);
}
}
// Generate a table lookup.
return EmitTableSwitch(sw, index_operand);
......
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