agx: Make DCE dumber

The current DCE pass hits issue around phi nodes. These need to be
solved properly eventually, but for now workaround them by doing
something obviously correct (but suboptimal compile time).

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
This commit is contained in:
Alyssa Rosenzweig
2022-04-13 18:34:50 -04:00
committed by Alyssa Rosenzweig
parent 606d9340f3
commit 4791dc9125
+18 -11
View File
@@ -28,10 +28,22 @@
void
agx_dce(agx_context *ctx)
{
BITSET_WORD *seen = calloc(BITSET_WORDS(ctx->alloc), sizeof(BITSET_WORD));
bool progress;
do {
progress = false;
BITSET_WORD *seen = calloc(BITSET_WORDS(ctx->alloc), sizeof(BITSET_WORD));
agx_foreach_instr_global(ctx, I) {
agx_foreach_src(I, s) {
if (I->src[s].type == AGX_INDEX_NORMAL)
BITSET_SET(seen, I->src[s].value);
}
}
agx_foreach_instr_global_safe_rev(ctx, I) {
if (!agx_opcodes_info[I->op].can_eliminate) continue;
agx_foreach_instr_global_safe_rev(ctx, I) {
if (agx_opcodes_info[I->op].can_eliminate) {
bool needed = false;
agx_foreach_dest(I, d) {
@@ -43,15 +55,10 @@ agx_dce(agx_context *ctx)
if (!needed) {
agx_remove_instruction(I);
continue;
progress = true;
}
}
agx_foreach_src(I, s) {
if (I->src[s].type == AGX_INDEX_NORMAL)
BITSET_SET(seen, I->src[s].value);
}
}
free(seen);
free(seen);
} while (progress);
}