Skip to content
Snippets Groups Projects
Commit 3b7fb892 authored by Gert Wollny's avatar Gert Wollny
Browse files

r600/sfn: Don't try to re-use the iterator when uses is updated

It seems on libc++ the iterator is invalidated when an element is removed
from the set, so restart iteration.

Fixes: f3415c (r600/sfn: copy propagate register load chains)

Closes: mesa/mesa#7931



Signed-off-by: default avatarGert Wollny <gert.wollny@collabora.com>
parent 499e3306
No related branches found
No related tags found
No related merge requests found
Pipeline #766640 waiting for manual action
...@@ -360,41 +360,55 @@ CopyPropFwdVisitor::visit(AluInstr *instr) ...@@ -360,41 +360,55 @@ CopyPropFwdVisitor::visit(AluInstr *instr)
auto src = instr->psrc(0); auto src = instr->psrc(0);
auto dest = instr->dest(); auto dest = instr->dest();
for (auto& i : dest->uses()) { bool local_progress = false;
/* SSA can always be propagated, registers only in the same block do {
local_progress = false;
for (auto& i : dest->uses()) {
/* SSA can always be propagated, registers only in the same block
* and only if they are assigned in the same block */ * and only if they are assigned in the same block */
bool can_propagate = dest->has_flag(Register::ssa); bool can_propagate = dest->has_flag(Register::ssa);
if (!can_propagate) { if (!can_propagate) {
/* Register can propagate if the assigment was in the same /* Register can propagate if the assigment was in the same
* block, and we don't have a second assignment coming later * block, and we don't have a second assignment coming later
* (e.g. helper invocation evaluation does * (e.g. helper invocation evaluation does
* *
* 1: MOV R0.x, -1 * 1: MOV R0.x, -1
* 2: FETCH R0.0 VPM * 2: FETCH R0.0 VPM
* 3: MOV SN.x, R0.x * 3: MOV SN.x, R0.x
* *
* Here we can't prpagate the move in 1 to SN.x in 3 */ * Here we can't prpagate the move in 1 to SN.x in 3 */
if ((instr->block_id() == i->block_id() && instr->index() < i->index())) { if ((instr->block_id() == i->block_id() && instr->index() < i->index())) {
can_propagate = true; can_propagate = true;
if (dest->parents().size() > 1) { if (dest->parents().size() > 1) {
for (auto p : dest->parents()) { for (auto p : dest->parents()) {
if (p->block_id() == i->block_id() && p->index() > instr->index()) { if (p->block_id() == i->block_id() && p->index() > instr->index()) {
can_propagate = false; can_propagate = false;
break; break;
}
} }
} }
} }
} }
}
if (can_propagate) { if (can_propagate) {
sfn_log << SfnLog::opt << " Try replace in " << i->block_id() << ":" sfn_log << SfnLog::opt << " Try replace in " << i->block_id() << ":"
<< i->index() << *i << "\n"; << i->index() << *i << "\n";
progress |= i->replace_source(dest, src);
/* A successful copy propagation may break the interator i, because
* the uses set changes (it does so with libc++), therefore restart
* the iteration after each successful propagation.
* TODO: rewite this to not restart iterating uses each time */
if (i->replace_source(dest, src)) {
local_progress = true;
break;
}
}
} }
} } while (local_progress);
progress |= local_progress;
if (instr->dest()) { if (instr->dest()) {
sfn_log << SfnLog::opt << "has uses; " << instr->dest()->uses().size(); sfn_log << SfnLog::opt << "has uses; " << instr->dest()->uses().size();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment