From 7dfa54399cd42715f29821bb0c2ac3b58394e37c Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Wed, 7 Jun 2017 01:55:26 +0300 Subject: [PATCH] ac/nir: convert several ifs to a switch Also solve "outinfo may be used uninitialized" warning by putting in an unreachable(). Signed-off-by: Grazvydas Ignotas Reviewed-by: Bas Nieuwenhuizen --- src/amd/common/ac_nir_to_llvm.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 02281904f80..42be6de99c9 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -5760,23 +5760,25 @@ ac_nir_eliminate_const_vs_outputs(struct nir_to_llvm_context *ctx) { struct ac_vs_output_info *outinfo; - if (ctx->stage == MESA_SHADER_FRAGMENT || - ctx->stage == MESA_SHADER_COMPUTE || - ctx->stage == MESA_SHADER_TESS_CTRL || - ctx->stage == MESA_SHADER_GEOMETRY) + switch (ctx->stage) { + case MESA_SHADER_FRAGMENT: + case MESA_SHADER_COMPUTE: + case MESA_SHADER_TESS_CTRL: + case MESA_SHADER_GEOMETRY: return; - - if (ctx->stage == MESA_SHADER_VERTEX) { + case MESA_SHADER_VERTEX: if (ctx->options->key.vs.as_ls || ctx->options->key.vs.as_es) return; outinfo = &ctx->shader_info->vs.outinfo; - } - - if (ctx->stage == MESA_SHADER_TESS_EVAL) { + break; + case MESA_SHADER_TESS_EVAL: if (ctx->options->key.vs.as_es) return; outinfo = &ctx->shader_info->tes.outinfo; + break; + default: + unreachable("Unhandled shader type"); } ac_optimize_vs_outputs(&ctx->ac, -- 2.30.2