Commit c14b3e4d authored by JialuZhang-intel's avatar JialuZhang-intel Committed by V8 LUCI CQ

[regalloc] add hint for operands in gap moves.

To eliminate unnecessary move instructions from register to fixed register. We check the fixed register hint for operands in move gaps
when building LiveRanges. If a to_operand has a hint_operand (with fixed register), then set the hint_operand for from_operand too. This can avoid the register allocator ignore hint information about fixed register.

Bug: v8:12909
Change-Id: I17f9afa484ee08de8ac1ab42945caba2c362fc9e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3669019Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Jialu Zhang <jialu.zhang@intel.com>
Cr-Commit-Position: refs/heads/main@{#80844}
parent b5283a2e
......@@ -220,6 +220,13 @@ bool UsePosition::HintRegister(int* register_code) const {
UNREACHABLE();
}
InstructionOperand* UsePosition::GetHintOperand() const {
if (HintTypeField::decode(flags_) == UsePositionHintType::kOperand) {
return reinterpret_cast<InstructionOperand*>(hint_);
}
return nullptr;
}
UsePositionHintType UsePosition::HintTypeForOperand(
const InstructionOperand& op) {
switch (op.kind()) {
......@@ -2314,6 +2321,20 @@ void LiveRangeBuilder::ProcessInstructions(const InstructionBlock* block,
cur->Eliminate();
continue;
}
// Check if to_operand already has a hint_operand(with fixed
// register), if true, set the hint_operand for from_operand to
// avoid this important hint information be ignored by register
// allocator.
int hint_reg = kUnassignedRegister;
UsePosition* hint_pos = to_range->FirstHintPosition(&hint_reg);
if (hint_pos != nullptr) {
DCHECK_NE(hint_reg, kUnassignedRegister);
InstructionOperand* hint_operand = hint_pos->GetHintOperand();
if (hint_operand->IsAnyLocationOperand()) {
hint = hint_operand;
hint_type = UsePosition::HintTypeForOperand(*hint_operand);
}
}
}
} else {
Define(curr_position, &to, spill_mode);
......
......@@ -502,6 +502,7 @@ class V8_EXPORT_PRIVATE UsePosition final
bool IsResolved() const {
return hint_type() != UsePositionHintType::kUnresolved;
}
InstructionOperand* GetHintOperand() const;
static UsePositionHintType HintTypeForOperand(const InstructionOperand& op);
private:
......
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