agx: Remove else optimization
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 13 Apr 2022 03:18:03 +0000 (23:18 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 2 May 2022 02:00:00 +0000 (22:00 -0400)
It will conflict with SSA-based RA and needs to be rewritten to happen
late.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>

src/asahi/compiler/agx_compile.c

index a38d9b2..c630e8c 100644 (file)
@@ -1093,18 +1093,14 @@ emit_cf_list(agx_context *ctx, struct exec_list *list);
  *       ...
  *    pop_exec
  *
- * If the else is empty, we can omit the else_icmp. This is not usually
- * optimal, but it's a start.
+ * If the else is empty, we can omit the else_icmp. This happens elsewhere, as
+ * an empty else block can become nonempty after RA due to phi lowering. This is
+ * not usually optimal, but it's a start.
  */
 
 static void
 emit_if(agx_context *ctx, nir_if *nif)
 {
-   nir_block *nir_else_block = nir_if_first_else_block(nif);
-   bool empty_else_block =
-      (nir_else_block == nir_if_last_else_block(nif) &&
-       exec_list_is_empty(&nir_else_block->instr_list));
-
    agx_block *first_block = ctx->current_block;
    agx_builder _b = agx_init_builder(ctx, agx_after_block(first_block));
    agx_index cond = agx_src_index(&nif->condition);
@@ -1116,10 +1112,8 @@ emit_if(agx_context *ctx, nir_if *nif)
    agx_block *if_block = emit_cf_list(ctx, &nif->then_list);
    agx_block *end_then = ctx->current_block;
 
-   if (!empty_else_block) {
-      _b.cursor = agx_after_block(ctx->current_block);
-      agx_else_icmp(&_b, cond, agx_zero(), 1, AGX_ICOND_UEQ, false);
-   }
+   _b.cursor = agx_after_block(ctx->current_block);
+   agx_else_icmp(&_b, cond, agx_zero(), 1, AGX_ICOND_UEQ, false);
 
    agx_block *else_block = emit_cf_list(ctx, &nif->else_list);
    agx_block *end_else = ctx->current_block;