Commit 8c42bd9e authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen Committed by Commit Bot

Avoid theoretical quadratic runtime on removing redundant moves

Change-Id: I3b9a85e53333349b30f3acb6219e7e47861ca042
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1491596Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60424}
parent f927e319
......@@ -93,20 +93,23 @@ void GapResolver::Resolve(ParallelMove* moves) {
// detect simple non-overlapping moves, and collect FP move representations if
// aliasing is non-simple.
int fp_reps = 0;
for (auto it = moves->begin(); it != moves->end();) {
MoveOperands* move = *it;
size_t nmoves = moves->size();
for (size_t i = 0; i < nmoves;) {
MoveOperands* move = (*moves)[i];
if (move->IsRedundant()) {
it = moves->erase(it);
nmoves--;
if (i < nmoves) (*moves)[i] = (*moves)[nmoves];
continue;
}
i++;
source_kinds.Add(GetKind(move->source()));
destination_kinds.Add(GetKind(move->destination()));
if (!kSimpleFPAliasing && move->destination().IsFPRegister()) {
fp_reps |= RepresentationBit(
LocationOperand::cast(move->destination()).representation());
}
++it;
}
if (nmoves != moves->size()) moves->resize(nmoves);
if ((source_kinds & destination_kinds).empty() || moves->size() < 2) {
// Fast path for non-conflicting parallel moves.
......
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