Avoid theoretical quadratic runtime on removing redundant moves
Change-Id: I3b9a85e53333349b30f3acb6219e7e47861ca042 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1491596 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#60424}
This commit is contained in:
parent
f927e31929
commit
8c42bd9ea4
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user