From dbe4947c662956171788d4b9502baf2daa7acca1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 19 Apr 2022 14:06:09 -0400 Subject: [PATCH] pan/bi: Use bi_worklist for post-RA liveness Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_opt_dce.c | 41 ++++++++++++++------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/panfrost/bifrost/bi_opt_dce.c b/src/panfrost/bifrost/bi_opt_dce.c index 85182d6..abb2600 100644 --- a/src/panfrost/bifrost/bi_opt_dce.c +++ b/src/panfrost/bifrost/bi_opt_dce.c @@ -115,40 +115,29 @@ bi_postra_liveness_block(bi_block *blk) void bi_postra_liveness(bi_context *ctx) { - struct set *work_list = _mesa_set_create(NULL, - _mesa_hash_pointer, - _mesa_key_pointer_equal); - - struct set *visited = _mesa_set_create(NULL, - _mesa_hash_pointer, - _mesa_key_pointer_equal); - - struct set_entry *cur; - cur = _mesa_set_add(work_list, pan_exit_block(&ctx->blocks)); + u_worklist worklist; + bi_worklist_init(ctx, &worklist); bi_foreach_block(ctx, block) { block->reg_live_out = block->reg_live_in = 0; - } - - do { - bi_block *blk = (struct bi_block *) cur->key; - _mesa_set_remove(work_list, cur); - /* Update its liveness information */ - bool progress = bi_postra_liveness_block(blk); + bi_worklist_push_tail(&worklist, block); + } - /* If we made progress, we need to process the predecessors */ + while (!u_worklist_is_empty(&worklist)) { + /* Pop off in reverse order since liveness is backwards */ + bi_block *blk = bi_worklist_pop_tail(&worklist); - if (progress || !_mesa_set_search(visited, blk)) { - bi_foreach_predecessor((blk), pred) - _mesa_set_add(work_list, pred); + /* Update liveness information. If we made progress, we need to + * reprocess the predecessors + */ + if (bi_postra_liveness_block(blk)) { + bi_foreach_predecessor(blk, pred) + bi_worklist_push_head(&worklist, pred); } + } - _mesa_set_add(visited, blk); - } while((cur = _mesa_set_next_entry(work_list, NULL)) != NULL); - - _mesa_set_destroy(visited, NULL); - _mesa_set_destroy(work_list, NULL); + u_worklist_fini(&worklist); } void -- 2.7.4