From 3958f00215c53c29aa6681f2af72cca7ec84b9bf Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 11 Aug 2021 10:31:48 -0400 Subject: [PATCH] pan/bi: Add a noopt debug option To rule out buggy optimization passes when debugging. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost.h | 1 + src/panfrost/bifrost/bifrost_compile.c | 29 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 74b110f204c..b0b8495ed2c 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -38,6 +38,7 @@ #define BIFROST_DBG_NOSCHED 0x0020 #define BIFROST_DBG_INORDER 0x0040 #define BIFROST_DBG_NOVALIDATE 0x0080 +#define BIFROST_DBG_NOOPT 0x0100 extern int bifrost_debug; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 5234cc22f75..d480431908b 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -46,6 +46,7 @@ static const struct debug_named_value bifrost_debug_options[] = { {"nosched", BIFROST_DBG_NOSCHED, "Force trivial bundling"}, {"inorder", BIFROST_DBG_INORDER, "Force in-order bundling"}, {"novalidate",BIFROST_DBG_NOVALIDATE, "Skip IR validation"}, + {"noopt", BIFROST_DBG_NOOPT, "Skip optimization passes"}, DEBUG_NAMED_VALUE_END }; @@ -3676,24 +3677,27 @@ bifrost_compile_shader_nir(nir_shader *nir, bi_emit_atest(&b, bi_zero()); } + bool optimize = !(bifrost_debug & BIFROST_DBG_NOOPT); + /* Runs before constant folding */ bi_lower_swizzle(ctx); bi_validate(ctx, "Early lowering"); /* Runs before copy prop */ - if (!ctx->inputs->no_ubo_to_push) { + if (optimize && !ctx->inputs->no_ubo_to_push) { bi_opt_push_ubo(ctx); } - bi_opt_constant_fold(ctx); - - bi_opt_copy_prop(ctx); - bi_opt_mod_prop_forward(ctx); - bi_opt_mod_prop_backward(ctx); - bi_opt_dead_code_eliminate(ctx); - bi_opt_cse(ctx); - bi_opt_dead_code_eliminate(ctx); - bi_validate(ctx, "Optimization passes"); + if (likely(optimize)) { + bi_opt_constant_fold(ctx); + bi_opt_copy_prop(ctx); + bi_opt_mod_prop_forward(ctx); + bi_opt_mod_prop_backward(ctx); + bi_opt_dead_code_eliminate(ctx); + bi_opt_cse(ctx); + bi_opt_dead_code_eliminate(ctx); + bi_validate(ctx, "Optimization passes"); + } bi_foreach_block(ctx, block) { bi_lower_branch(block); @@ -3710,7 +3714,10 @@ bifrost_compile_shader_nir(nir_shader *nir, bi_validate(ctx, "Late lowering"); bi_register_allocate(ctx); - bi_opt_post_ra(ctx); + + if (likely(optimize)) + bi_opt_post_ra(ctx); + if (bifrost_debug & BIFROST_DBG_SHADERS && !skip_internal) bi_print_shader(ctx, stdout);